[英]Android form orientation change issue
Hi am trying to design a layout for a password change activity. 您好,我正在尝试设计用于密码更改活动的布局。 I have made it, but when the screen orientation changes it looks weird.
我已经做到了,但是当屏幕方向改变时,看起来很奇怪。
for landscape mode it looks good and i have designed the layout in that graphical mode with relative layout and my edittext fields are center aligned and my textviews are left aligned to it. 对于横向模式,它看起来不错,我已经在具有相对布局的图形模式下设计了布局,而我的edittext字段居中对齐,而textview则与之对齐。 while i change it to portrait , the edittext are center aligned and my textview dont have space to fit in screen.
当我将其更改为portrait时,edittext居中对齐,并且textview没有足够的空间适合屏幕。 I don't have much reputations to post my screenshots.
我没有很多声誉可以发布我的屏幕截图。 So please understand it and help me
所以请理解并帮助我
how can i design it for looking good at both orientations 我如何设计才能在两个方向都看起来不错
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/imageButton1"
android:layout_below="@+id/imageButton2"
android:layout_marginTop="15dp"
android:background="@color/white" >
<EditText
android:id="@+id/currentPwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp"
android:background="@drawable/pwd_txt_box"
android:ems="10"
android:inputType="textPassword" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/currentPwd"
android:layout_alignBottom="@+id/currentPwd"
android:layout_marginRight="42dp"
android:layout_toLeftOf="@+id/currentPwd"
android:text="@string/current_password"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/newPwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/currentPwd"
android:layout_marginTop="24dp"
android:layout_toRightOf="@+id/textView2"
android:background="@drawable/pwd_txt_box"
android:ems="10"
android:inputType="textPassword" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/newPwd"
android:layout_alignBottom="@+id/newPwd"
android:layout_alignLeft="@+id/textView2"
android:text="@string/new_password"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/confirmPwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/newPwd"
android:layout_below="@+id/newPwd"
android:layout_marginTop="26dp"
android:background="@drawable/pwd_txt_box"
android:ems="10"
android:inputType="textPassword" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/confirmPwd"
android:layout_alignBottom="@+id/confirmPwd"
android:layout_alignLeft="@+id/textView3"
android:text="@string/confirm_password"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
this is my xml layout code 这是我的xml布局代码
Hi You need to create two different layout for landscape and portrait mode try this and create a new folders has 嗨,您需要为横向和纵向模式创建两个不同的布局,尝试此操作并创建一个新文件夹
res/
layout/ # default (portrait)
main.xml
layout-land/ # landscape
main.xml
layout-large/ # large (portrait)
main.xml
layout-large-land/ # large landscape
main.xml
I hope this help you 希望对您有帮助
在res文件夹中创建layout-land。将您的xml粘贴到其中,并针对该文件夹中的横向调整布局,对于肖像使用简单的布局文件夹进行调整,并对其中的肖像进行更改。
By default, the layouts in /res/layout
are applied to both portrait and landscape. 默认情况下,
/res/layout
同时应用于纵向和横向。
If you have for example 如果你有例如
/res/layout/main.xml
Add a new folder /res/layout-land
, copy main.xml
into it and make the needed adjustments. 添加一个新文件夹
/res/layout-land
,将main.xml
复制到其中并进行所需的调整。
1.) create folder /res/layout-land (here you will keep your landscape adjusted layouts)
2.) copy home.xml there
3.) make necessary changes to it
For more information go with this link 有关更多信息,请点击此链接
Also see http://www.androidpeople.com/android-portrait-amp-landscape-differeent-layouts and http://www.devx.com/wireless/Article/40792/1954 for some more options. 另请参阅http://www.androidpeople.com/android-portrait-amp-landscape-differeent-layouts和http://www.devx.com/wireless/Article/40792/1954 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.