【发布时间】:2019-10-08 06:34:35
【问题描述】:
我想为我的应用创建这种类型的布局,有人可以帮我吗。我怎样才能创建这种类型的布局?
【问题讨论】:
-
使用框架布局。背面的图像和顶部的按钮。设置按钮可点击:false 所以你的图片会收到点击
标签: android android-layout android-linearlayout
我想为我的应用创建这种类型的布局,有人可以帮我吗。我怎样才能创建这种类型的布局?
【问题讨论】:
标签: android android-layout android-linearlayout
对于一个按钮,这也很好用。放 android:background 就好了!
<Button
android:id="@+id/fragment_left_menu_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_bg"
android:text="@string/login_string" />
【讨论】:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_marginTop="5dp"
android:layout_weight="2"
android:background="@drawable/images"
android:gravity="center">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/style"
android:text="Pasta"
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_marginTop="5dp"
android:layout_weight="2"
android:background="@drawable/images"
android:gravity="center">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/style"
android:text="Pasta"
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_marginTop="5dp"
android:layout_weight="2"
android:background="@drawable/images"
android:gravity="center">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/style"
android:text="Pasta"
android:textColor="#ffffff" />
</LinearLayout>
</LinearLayout>
在你的drawable中创建一个样式文件
<?xml version="1.0" encoding="UTF-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1dp"
android:color="#FFFFFF"/>
<corners
android:radius="7dp" />
<padding
android:left="1dp"
android:right="1dp"
android:top="1dp"
android:bottom="1dp"/>
<solid android:color="#55ffffff"/>
</shape>
【讨论】:
在这种情况下,您可以使用 MaterialButton。
<com.google.android.material.button.MaterialButton
android:layout_width="match_parent"
android:layout_height="65dp"
android:text="Non vegetarian"
android:textColor="@color/colorPrimary"
android:textAllCaps="false"
android:background="@drawable/bg_rounded_btn"
app:backgroundTint="@drawable/bg_rounded_btn" />
@drawable/bg_rounded_btn 文件:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp" />
// In your case color transparent
<solid android:color="@color/white" />
// In your case color white
<stroke
android:width="1dp"
android:color="@color/scooter_dark" />
</shape>
【讨论】: