Android:线性布局的边界
我有一个线性布局,我想为它设置一个边界。它应该如下所示 这是我的布局Android:线性布局的边界,android,android-studio,border,android-linearlayout,Android,Android Studio,Border,Android Linearlayout,我有一个线性布局,我想为它设置一个边界。它应该如下所示 这是我的布局 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.andr
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".activities.AddInfoMainActivity"
tools:showIn="@layout/app_bar_main">
<LinearLayout
android:id="@+id/add_info_layout_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/add_info_layout_one_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:id="@+id/add_info_layout_one_img01"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="24dp"
android:src="@drawable/sample01" />
<TextView
android:id="@+id/add_info_layout_one_txtView01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/add_info_txt_one_01"
android:textAlignment="center"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/add_info_layout_one_two"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:id="@+id/add_info_layout_one_img02"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="24dp"
android:src="@drawable/sample02" />
<TextView
android:id="@+id/add_info_layout_one_txtView02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/add_info_txt_one_02"
android:textAlignment="center"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Util到现在为止,我还没有为我的布局使用任何样式
有什么想法吗?要设置边框,您可以使用以下代码在绘图表中创建一个xml文件 border.xml 从你的直线布局中,列出你的背景
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com....
android:background="@drawable/border">
<!--- code here --->
</LinearLayout>
但基于您的图像,您正在寻找cardView。尝试搜索cardview
单击此示例和cardview教程 要设置边框,您可以使用下面的代码在绘图表中创建一个xml文件 border.xml 从你的直线布局中,列出你的背景
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com....
android:background="@drawable/border">
<!--- code here --->
</LinearLayout>
但基于您的图像,您正在寻找cardView。尝试搜索cardview
单击此示例和cardview教程 试着这样做:
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_5sdp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="@dimen/_3sdp">
<LinearLayout
android:id="@+id/add_info_layout_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/add_info_layout_one_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:id="@+id/add_info_layout_one_img01"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="24dp"
android:src="@drawable/sample01" />
<TextView
android:id="@+id/add_info_layout_one_txtView01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/add_info_txt_one_01"
android:textAlignment="center"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
试着这样做:
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_5sdp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="@dimen/_3sdp">
<LinearLayout
android:id="@+id/add_info_layout_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/add_info_layout_one_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:id="@+id/add_info_layout_one_img01"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="24dp"
android:src="@drawable/sample01" />
<TextView
android:id="@+id/add_info_layout_one_txtView01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/add_info_txt_one_01"
android:textAlignment="center"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
如果您想要阴影效果,请使用卡片视图。添加卡片高程属性卡片\视图:cardElevation=4dp根据需要设置dp 或者将此可绘制文件添加到可绘制文件夹中
如果您想要阴影效果,请使用卡片视图。添加卡片高程属性卡片\视图:cardElevation=4dp根据需要设置dp 或者将此可绘制文件添加到可绘制文件夹中
你试过什么?机器人:仰角?九块背景图像?还有什么吗?您必须使用card view作为父视图,并且必须使用图像和文本的线性布局。在cardview属性中设置所需的高程改为使用cardview小部件绘制线性布局。没有看到您的努力!!无论如何,请参考与卡片视图一起使用的循环视图。这正是您想要的相同UI。您还可以为drawable创建一个形状,并将其设置为布局的android:background。您尝试了什么?机器人:仰角?九块背景图像?还有什么吗?您必须使用card view作为父视图,并且必须使用图像和文本的线性布局。在cardview属性中设置所需的高程改为使用cardview小部件绘制线性布局。没有看到您的努力!!无论如何,请参考与卡片视图一起使用的循环视图。这是与您想要的完全相同的UI。您还可以为drawable创建一个形状,并将其设置为布局的android:background