Android 底部有两个按钮的文本视图
我需要在XML中使用底部两个按钮的简单文本视图 像这样 我曾尝试使用底部的两个按钮,使用相对视图,但未能成功,无法添加文本视图。任何人都有任何想法,请尝试此操作Android 底部有两个按钮的文本视图,android,layout,Android,Layout,我需要在XML中使用底部两个按钮的简单文本视图 像这样 我曾尝试使用底部的两个按钮,使用相对视图,但未能成功,无法添加文本视图。任何人都有任何想法,请尝试此操作 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" a
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_marginTop="12dp"
android:text="button1" />
<Button
android:id="@+id/btn_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_marginTop="12dp"
android:text="button2" />
</LinearLayout>
</RelativeLayout>
使用此布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@android:style/TextAppearance.Large"
android:text="ABC"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:padding="5dp">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="button1" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="button2" />
</LinearLayout>
</RelativeLayout>
希望这对您有所帮助。您能告诉我们您到目前为止做了什么吗?告诉我们您尝试了什么。不要这样做。我们在谷歌的好朋友花时间创建了一个
RelativeLayout
,所以你不必这么做