简体   繁体   中英

how to move the widgets around in an linearlayout

I have a LinearLayout with orientation as horizontal and would like to place a button at a particular distance from a TextView, how to do it. Can you post a link of tutorial showing positioning of different widgets in various layouts. Thanks.

Common Layout Objects | Android Developers is quite useful, especially if you're looking for something more example-fed. If you're looking for pure documentation, everything is here: User Interface | Android Developers

For spacing objects, there are a lot of options, but the most straightforward is to just set the margin of either element:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" android:orientation="horizontal">
    <TextView android:text="TextView" 
        android:id="@+id/editText1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"></TextView>
    <Button android:id="@+id/button1" 
        android:layout_marginLeft="50dip" 
        android:text="Button" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content"></Button>
</LinearLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM