Android 内部布局顶部边缘上的图像
我怎样才能像下图一样将小的圆形图像放在边缘上(这是我需要复制的实际设计): 更新:到目前为止,按如下方式完成: 现在如何解决重叠问题(表单布局重叠圆形图像)? 更新:完成强>Android 内部布局顶部边缘上的图像,android,xml,android-layout,layout,Android,Xml,Android Layout,Layout,我怎样才能像下图一样将小的圆形图像放在边缘上(这是我需要复制的实际设计): 更新:到目前为止,按如下方式完成: 现在如何解决重叠问题(表单布局重叠圆形图像)? 更新:完成 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:bac
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/back" >
<!-- Put everything contained in the white area in this layout -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:background="@android:color/transparent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:background="@color/White"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="60dp" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name:" />
<EditText
android:id="@+id/name_editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email:" />
<EditText
android:id="@+id/email_editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Email"
android:inputType="textEmailAddress" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email:" />
<EditText
android:id="@+id/phone_editText3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Phone"
android:inputType="phone" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Birthday:" />
<EditText
android:id="@+id/birth_editText4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:editable="false"
android:ems="10"
android:hint="Birthday"
android:inputType="date" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Password:" />
<EditText
android:id="@+id/pass_editText6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Password"
android:inputType="textPassword" />
</LinearLayout>
<Button
android:id="@+id/register_button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Register" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:scaleType="fitXY"
android:src="@drawable/signup" />
</RelativeLayout>
我建议使用RelativeLayout。我将举一个粗略的例子:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
// The Image you want to put on the top edge
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="@drawable/image" />
// Put everything contained in the white area in this layout
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
// Since there is now way to align the ImageView with top edge, just move
// this layout down for half of the height of the image.
android:layout_marginTop="@dimen/half_image_height">
...
</RelativeLayout>
</RelativeLayout>
//要放在顶部边缘的图像
//将白色区域中包含的所有内容放入此布局中
...
我建议使用RelativeLayout。我将举一个粗略的例子:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
// The Image you want to put on the top edge
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="@drawable/image" />
// Put everything contained in the white area in this layout
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
// Since there is now way to align the ImageView with top edge, just move
// this layout down for half of the height of the image.
android:layout_marginTop="@dimen/half_image_height">
...
</RelativeLayout>
</RelativeLayout>
//要放在顶部边缘的图像
//将白色区域中包含的所有内容放入此布局中
...
您可以尝试此布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/yourLinearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp">
<!-- YOUR CONTENT -->
</LinearLayout>
<ImageView
android:id="@+id/yourRoundedImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignTop="@id/yourLinearLayout"
android:layout_marginTop="@dimen/halfHeightOfYourImage"/>
</RelativeLayout>
希望这有帮助您可以尝试此布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/yourLinearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp">
<!-- YOUR CONTENT -->
</LinearLayout>
<ImageView
android:id="@+id/yourRoundedImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignTop="@id/yourLinearLayout"
android:layout_marginTop="@dimen/halfHeightOfYourImage"/>
</RelativeLayout>
希望这能有所帮助我同意@Rahul Gupta的答案,但我不想使用背景图像,而是想使用
RelativeLayout
ImageView
与“铅笔”图像一起使用,并将其与屏幕顶部中心对齐LinearLayout
和不要提及下面的android:layout\u属性。这将导致LinearLayout再次从屏幕开始。现在使用android:margin\u top属性,将其设置为某个值,使布局向下移动到图像的一半TextView
s和EditText
s祝你好运 我同意@Rahul Gupta的答案,但我不想使用背景图像,而是想使用
相对论yout
ImageView
与“铅笔”图像一起使用,并将其与屏幕顶部中心对齐LinearLayout
和不要提及下面的android:layout\u属性。这将导致LinearLayout再次从屏幕开始。现在使用android:margin\u top属性,将其设置为某个值,使布局向下移动到图像的一半TextView
s和EditText
s祝你好运 下面的示例与您所需的一样。。。。 可能有助于设计您的布局。。。。
文件名edit_text_shap.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="@android:color/darker_gray" />
<stroke
android:width="1dp"
android:color="#CCCCCC" />
<corners android:radius="8dip"/>
</shape>
以下示例与您所需的示例类似。。。。 可能有助于设计您的布局。。。。
文件名edit_text_shap.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="@android:color/darker_gray" />
<stroke
android:width="1dp"
android:color="#CCCCCC" />
<corners android:radius="8dip"/>
</shape>
我给出了正确的答案,但仍然投了反对票。无论如何,这是你问题的复制品。你可以自己编辑
<?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="@drawable/abc"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="100dp"
android:text="FirstName"
android:textSize="10sp" />
<EditText
android:id="@+id/editText1"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/textView1"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@id/textView1"
android:ems="10" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginTop="30dp"
android:text="LastName"
android:textSize="10sp" />
<EditText
android:id="@+id/editText2"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/textView2"
android:layout_below="@id/editText1"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@id/textView2"
android:ems="10" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_below="@+id/textView2"
android:layout_marginTop="30dp"
android:text="UserName"
android:textSize="10sp" />
<EditText
android:id="@+id/editText3"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/textView3"
android:layout_alignLeft="@+id/editText2"
android:layout_alignTop="@+id/textView3"
android:ems="10" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView3"
android:layout_centerVertical="true"
android:layout_marginTop="30dp"
android:text="Password"
android:textSize="10sp" />
<EditText
android:id="@+id/editText4"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/textView4"
android:layout_alignLeft="@+id/editText1"
android:layout_centerVertical="true"
android:ems="10"
android:inputType="textPassword" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/editText4"
android:layout_below="@+id/textView5"
android:text="Agreed and consent to our Terms of Service"
android:textSize="10sp" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView6"
android:layout_below="@+id/editText4"
android:layout_marginTop="44dp"
android:text="Terms & Conditions"
android:textStyle="bold" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView6"
android:layout_below="@+id/textView6"
android:layout_marginTop="27dp"
android:text="Create New Account" />
</RelativeLayout>
我发布了正确的答案,但仍然投了反对票。无论如何,这是你问题的复制品。你可以自己编辑
<?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="@drawable/abc"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="100dp"
android:text="FirstName"
android:textSize="10sp" />
<EditText
android:id="@+id/editText1"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/textView1"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@id/textView1"
android:ems="10" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginTop="30dp"
android:text="LastName"
android:textSize="10sp" />
<EditText
android:id="@+id/editText2"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/textView2"
android:layout_below="@id/editText1"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@id/textView2"
android:ems="10" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_below="@+id/textView2"
android:layout_marginTop="30dp"
android:text="UserName"
android:textSize="10sp" />
<EditText
android:id="@+id/editText3"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/textView3"
android:layout_alignLeft="@+id/editText2"
android:layout_alignTop="@+id/textView3"
android:ems="10" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView3"
android:layout_centerVertical="true"
android:layout_marginTop="30dp"
android:text="Password"
android:textSize="10sp" />
<EditText
android:id="@+id/editText4"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/textView4"
android:layout_alignLeft="@+id/editText1"
android:layout_centerVertical="true"
android:ems="10"
android:inputType="textPassword" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/editText4"
android:layout_below="@+id/textView5"
android:text="Agreed and consent to our Terms of Service"
android:textSize="10sp" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView6"
android:layout_below="@+id/editText4"
android:layout_marginTop="44dp"
android:text="Terms & Conditions"
android:textStyle="bold" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView6"
android:layout_below="@+id/textView6"
android:layout_marginTop="27dp"
android:text="Create New Account" />
</RelativeLayout>
//试试这个
//试试这个
我知道我迟到了,但我也想发布我的代码,这对我来说非常合适
<RelativeLayout
style="@style/personal_info_page_layout"
android:layout_weight="1">
<View
android:id="@+id/vLogoImg"
android:layout_width="match_parent"
android:layout_height="@dimen/dimen100"
android:background="@color/colorPrimary"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="@+id/vLogoImg"
android:background="@mipmap/logo"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
只需根据您的要求设置图像和颜色。我知道我迟到了,但我也想发布我的代码,这对我来说非常适合
<RelativeLayout
style="@style/personal_info_page_layout"
android:layout_weight="1">
<View
android:id="@+id/vLogoImg"
android:layout_width="match_parent"
android:layout_height="@dimen/dimen100"
android:background="@color/colorPrimary"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="@+id/vLogoImg"
android:background="@mipmap/logo"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
只需根据您的要求设置图像和颜色。给出一个屏幕截图或其他东西。给出一个屏幕截图或其他东西。您建议使用相对线而不是像我的回答中那样的线性布局。RelativeLayout速度更快,并提供更多选项来自定义布局。当您有这么多内容时,RelativeLayout和LinearLayout之间的速度不会有任何提高。不过,在这里使用哪种布局并不重要。你可以建议使用RelativeLayout,而不是像我的answe中那样的线性布局