在android xml中将texttext放在textview的上方和下方(Placing edittext above and below textview in android xml)

编程入门 行业动态 更新时间:2024-10-27 12:36:33
在android xml中将texttext放在textview的上方和下方(Placing edittext above and below textview in android xml)

我试图在textview上面放置一个editview,它位于垂直和水平的中心。 和textview下面的其他editview。

我添加了广告布局,现在编辑视图显示在左上角。

我正在使用嵌套的相对布局。

这是代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:background="@drawable/love" tools:context="com.ashsoftapps.lovecalculator.MainActivity" > <RelativeLayout android:id="@+id/lay" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_above="@+id/adView" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="Txt " android:textSize="30dp" android:textStyle="bold" /> <EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/textView1" android:layout_marginBottom="30dp" android:ems="10" android:hint="Name 1" > <requestFocus /> </EditText> <EditText android:id="@+id/editText2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textView1" android:layout_marginTop="15dp" android:ems="10" android:hint="Name 2" /> <ImageButton android:id="@+id/imageButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="14dp" android:src="@drawable/sub" android:visibility="visible" /> </RelativeLayout> <com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" > </com.google.android.gms.ads.AdView>

I am trying to place one editview above the textview which is positioned in center vertical and horizontal. and other editview below the textview.

I added an ad layout and now the editview are shown at top left corners.

I am using nested relative layout.

Here is the code :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:background="@drawable/love" tools:context="com.ashsoftapps.lovecalculator.MainActivity" > <RelativeLayout android:id="@+id/lay" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_above="@+id/adView" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="Txt " android:textSize="30dp" android:textStyle="bold" /> <EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/textView1" android:layout_marginBottom="30dp" android:ems="10" android:hint="Name 1" > <requestFocus /> </EditText> <EditText android:id="@+id/editText2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textView1" android:layout_marginTop="15dp" android:ems="10" android:hint="Name 2" /> <ImageButton android:id="@+id/imageButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="14dp" android:src="@drawable/sub" android:visibility="visible" /> </RelativeLayout> <com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" > </com.google.android.gms.ads.AdView>

最满意答案

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/love" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="Txt " android:textSize="30dp" android:textStyle="bold" /> <EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/textView1" android:layout_marginBottom="30dp" android:ems="10" android:hint="Name 1" > </EditText> <EditText android:id="@+id/editText2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textView1" android:layout_marginTop="15dp" android:ems="10" android:hint="Name 2" /> <ImageButton android:id="@+id/imageButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/adView" android:layout_centerHorizontal="true" android:layout_marginBottom="14dp" android:src="@drawable/sub" android:visibility="visible" /> <com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerInParent="true" > </com.google.android.gms.ads.AdView> </RelativeLayout> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/love" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="Txt " android:textSize="30dp" android:textStyle="bold" /> <EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/textView1" android:layout_marginBottom="30dp" android:ems="10" android:hint="Name 1" > </EditText> <EditText android:id="@+id/editText2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textView1" android:layout_marginTop="15dp" android:ems="10" android:hint="Name 2" /> <ImageButton android:id="@+id/imageButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/adView" android:layout_centerHorizontal="true" android:layout_marginBottom="14dp" android:src="@drawable/sub" android:visibility="visible" /> <com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerInParent="true" > </com.google.android.gms.ads.AdView> </RelativeLayout>

更多推荐

本文发布于:2023-08-01 10:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1358115.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:放在   中将   android   xml   texttext

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!