开发者

Which layout we have to use to place the text view and edit text at what ever position we want in android?

开发者 https://www.devze.com 2023-03-20 13:57 出处:网络
We are working on android project. We have placed background image wit开发者_开发技巧h Relative Layout. Now we want to place username and password with login button. Which layout we should use now? We

We are working on android project. We have placed background image wit开发者_开发技巧h Relative Layout. Now we want to place username and password with login button. Which layout we should use now? We are facing some problems in keeping those at our required position. What properties we have to set? Please send us sample code.

Thanks


I think RelativeLayout is best according your requirement ..

all layout sample code

plz see this link try to implement using relativelayout.

property of relative layout


First, make a layout xml similar to this.

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/marker_layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</RelativeLayout>

After that, instantiate a RelativeLayout base on that xml

 RelativeLayout rl = (RelativeLayout) findViewById(R.id.marker_layout);

From now on, just add your textview to rl with paramLayout like this.

RelativeLayout.LayoutParams param = new         RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
 param.leftMargin = your desired x coor;
 param.topMargin = your desired y coor;
 rl.addView(TextView,param);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号