Android 如何在一个视图上创建视图?
我正在创建一个简单的android应用程序。对于我的登录页面,我希望有一个背景图片和另一个顶部视图,就像下面的示例一样(假设黑色部分是我的背景图片,绿色部分是带有说明和两个按钮的视图!)现在,我将背景图片设置为我的相对布局活动,并且我正在使用警报对话框来显示我所说的视图 我想知道有没有更好更干净的方法?因为有了警报日志,我需要处理很多情况 多谢各位Android 如何在一个视图上创建视图?,android,android-relativelayout,Android,Android Relativelayout,我正在创建一个简单的android应用程序。对于我的登录页面,我希望有一个背景图片和另一个顶部视图,就像下面的示例一样(假设黑色部分是我的背景图片,绿色部分是带有说明和两个按钮的视图!)现在,我将背景图片设置为我的相对布局活动,并且我正在使用警报对话框来显示我所说的视图 我想知道有没有更好更干净的方法?因为有了警报日志,我需要处理很多情况 多谢各位 我建议您将活动的相对布局更改为线性布局(具有垂直方向属性),然后将图像和登录窗格添加到其中。 通过这种方式,您可以像行一样排列视图! 下面是一个简单
我建议您将活动的相对布局更改为线性布局(具有垂直方向属性),然后将图像和登录窗格添加到其中。 通过这种方式,您可以像行一样排列视图! 下面是一个简单的xml示例:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
inser the image view ..
insert the login pannel
</LinearLayout>
插入图像视图。。
插入登录窗格
试试这个
<?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="match_parent"
android:background="#000000"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#00FF00"
android:layout_margin="16dp" >
<TextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Description"
android:padding="16dp"
android:textColor="#FFFFFF" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/description"
android:orientation="horizontal"
android:weightSum="2" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="bottom"
android:padding="16dp"
android:text="Button1" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="16dp"
android:text="Button2" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
在相对布局中再添加一个Relativelayout,并设置layout\u alignParentBottom=“true”,然后在此新的相对布局中添加描述文本视图和按钮。嘿,感谢您的反馈!你的代码是工作,但在我的真实代码,而不是描述我想添加一个图像,但当我这样做,然后什么都没有出现!知道为什么吗?你想为底部视图设置背景图像,或者只在按钮上方设置一个图像视图。?而不是:我添加了这个