English 中文(简体)
底部和底土体组
原标题:android fit panel to bottom

我有两顿子,可以节省和取消。 当我上表时,关键板自动显示。 (Btw. Form有一个EditText)。 我确实知道如何把丁顿装到底部。 现在,塔顿被置于埃迪特提尔之下,我希望将其置于关键之上。

想看到法典的人:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/ScrollView01" android:layout_width="fill_parent" 
        android:layout_height="fill_parent">

    <LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" style="@style/Form">

        <LinearLayout android:id="@+id/linearLayout1" 
        android:layout_height="wrap_content" 
        android:layout_width="fill_parent"
        android:layout_margin="7dp"
        android:orientation="vertical">

            <EditText 
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content" 
                android:id="@+id/etNewListNameForm" 
                android:hint="list name"
                android:layout_marginLeft="1dp"
                android:layout_marginRight="1dp"></EditText>

        </LinearLayout>

        <LinearLayout style="@style/BottomPanel"
            android:id="@+id/linearLayout2"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <Button
                android:id="@+id/btnSaveCardList" 
                android:layout_width="fill_parent" android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_marginTop="5dp"
                android:text="Save"></Button>
            <Button
                android:id="@+id/btnCancelCardLst" 
                android:layout_width="fill_parent" android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_weight="1"
                android:text="Cancel"></Button>

        </LinearLayout>

    </LinearLayout>
</ScrollView>

最好

Images: enter image description here enter image description here

问题回答

你们的一种选择是使用相对布局,而不是线性,并使用方位。

    <RelativeLayout android:id="@+id/linearLayout1" 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent"
    android:layout_margin="7dp"
    android:orientation="vertical">

        <EditText 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:id="@+id/etNewListNameForm" 
            android:hint="list name"
            android:layout_marginLeft="1dp"
            android:layout_marginRight="1dp"></EditText>

    </LinearLayout>

    <LinearLayout style="@style/BottomPanel"
        android:id="@+id/linearLayout2"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentBottom="true">
        .....

Edit:同样值得注意的是,你应当认真考虑用更多的描述性名称来发表看法。 你在座标和埃德蒂特蒂特提尔使用描述性名称,但用线性语言1和线性语言2来看待你的布局。 考虑将其命名为主食、底层PannelLayout或某种东西,如果你试图说明你如何铺设道路,则会更容易铺设。

在载有您的EditText的线索中,改动android:layout_hal0dp和设定android:layout_rights/code>至1。 这样,在纽特小组接手后,它将在母体内吃掉其余部分。

...
    <LinearLayout android:id="@+id/linearLayout1" 
        android:layout_height="0dp"
        android:layout_weight="1"
        android:layout_width="fill_parent"
        android:layout_margin="7dp"
        android:orientation="vertical">

        <EditText 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:id="@+id/etNewListNameForm" 
            android:hint="list name"
            android:layout_marginLeft="1dp"
            android:layout_marginRight="1dp"></EditText>

    </LinearLayout>
...
  1. Wrap your ScrollView in a RelativeLayout,
  2. move the LinearLayout with the buttons to be the second child of that RelativeLayout,
  3. and set android:layout_alignParentBottom to true for that LinearLayout.

Remove unnecessary views and use relativeLayuot

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:background="#ff0022">


    <LinearLayout android:id="@+id/linearLayout2"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:layout_alignParentBottom="true">
        <Button android:layout_marginTop="5dp" android:text="Save"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:layout_weight="1" android:id="@+id/btnSaveCardList"></Button>
        <Button android:layout_marginTop="5dp" android:text="Cancel"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:layout_weight="1" android:id="@+id/btnCancelCardLst"></Button>

    </LinearLayout>
    <EditText android:layout_height="wrap_content"
        android:layout_margin="7dp" android:hint="list name"
        android:layout_width="fill_parent" android:id="@+id/etNewListNameForm"
        android:layout_alignParentTop="true" android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp">
        <requestFocus></requestFocus>
    </EditText>
</RelativeLayout>




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...