-1
<ScrollView
    android:id="@+id/scroll"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_marginTop="15dp"
    android:layout_marginRight="15dp"
    android:layout_marginLeft="15dp"
    android:layout_marginBottom="5dp"
    android:background="@drawable/background">
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <TextView 
            android:id="@+id/textt" 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            style="@style/textstyle" />  
    </LinearLayout> 
</ScrollView>
<Button
    android:id="@+id/nextbutton"
    style="@style/nextButton"
    android:background="@drawable/next_button"   
    android:text="@string/xxx"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:gravity="center"
    android:onClick="ethod" />    

テキストビューが非常に長い場合、スクロールがすべての画面を占有し、下部にあるはずのボタンやその他のものが表示されません。

4

5 に答える 5

0

よくわかりませんが、このアプローチを試すことができます。

あなたのXML:

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

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:layout_weight="0.25"
        android:editable="false"
        android:inputType="textMultiLine"
        android:text="This is very very very loooooooooooooonnnnnnnnnnnng textThis is very very very loooooooooooooonnnnnnnnnnnng textThis is very very very loooooooooooooonnnnnnnnnnnng textThis is very very very loooooooooooooonnnnnnnnnnnng textThis is very very very loooooooooooooonnnnnnnnnnnng textThis is very very very loooooooooooooonnnnnnnnnnnng textThis is very very very loooooooooooooonnnnnnnnnnnng textThis is very very very loooooooooooooonnnnnnnnnnnng text.This is very very very loooooooooooooonnnnnnnnnnnng text.This is very very very loooooooooooooonnnnnnnnnnnng text." >

        <requestFocus />
    </EditText>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="2dp"
        android:layout_marginRight="2dp"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/btn_chkin"
            android:layout_width="0dip"
            android:layout_height="50dip"
            android:layout_marginBottom="5dip"
            android:layout_marginRight="2dip"
            android:layout_marginTop="5dip"
            android:layout_weight="1"
            android:text="Accept" />
    </LinearLayout>

</LinearLayout>

そしてonCreate()あなたの活動の中で:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.test);
    EditText ed = (EditText) findViewById(R.id.editText1);
    ed.setSelection(0);
    ed.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            getWindow()
                    .setSoftInputMode(
                            WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        }
    });
}

これは完璧な解決策ではありませんが、近いものです。

于 2012-07-25T08:21:59.200 に答える
0

次のように、LayoutParams を使用して、RelativeLayout に ScrollView と ButtonView を配置します。

<RelativeLayout android:id="@+id/parent"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

<ScrollView
    android:id="@+id/scroll"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentTop="true"
    android:layout_above="@+id/nextbutton"
    android:layout_marginTop="15dp"
    android:layout_marginRight="15dp"
    android:layout_marginLeft="15dp"
    android:layout_marginBottom="5dp"
    android:background="@drawable/background">
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <TextView 
            android:id="@+id/textt" 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            style="@style/textstyle" />  
    </LinearLayout> 
</ScrollView>
<Button
    android:id="@+id/nextbutton"
    style="@style/nextButton"
    android:background="@drawable/next_button"   
    android:text="@string/xxx"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:gravity="center"
    android:onClick="ethod" /> 

</RelativeLayout?
于 2012-07-25T09:39:39.503 に答える
0
<?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:orientation="vertical" >

    <ScrollView
        android:id="@+id/scroll"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:layout_marginTop="15dp" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/textt"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="afgfffffffjbhhjkhholhjbhlkjhhhhhhhhhhhhhhhhhhhhhhhkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk" />
        </LinearLayout>
    </ScrollView>

    <Button
        android:id="@+id/nextbutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:gravity="center"
        android:onClick="ethod"
        android:text="button" />

</RelativeLayout>
于 2012-07-25T06:59:17.400 に答える
-1

LinearLayout を使用する場合 - Kumar が言ったように重みを使用します。あなたの問題での私の選択は、RelativeLayoutとScrollViewの「上」プロパティを使用することです(scrollViewの下に静的ボタンが必要な場合)。

ScrollView の TextView の下に Button が必要な場合は、ボタン要素を ScrollView に取り込みます。

于 2012-07-25T06:55:41.423 に答える
-1
        <ScrollView
android:id="@+id/scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="15dp"
android:layout_marginRight="15dp"
android:layout_marginLeft="15dp"
android:layout_marginBottom="40dip"
android:background="@drawable/background">
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView 
        android:id="@+id/textt" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        style="@style/textstyle" />  
</LinearLayout> 

<Button
android:id="@+id/nextbutton"
style="@style/nextButton"
android:background="@drawable/next_button"   
android:text="@string/xxx"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="center"
android:onClick="ethod"

Android:layout_width="fill_parent" Android:layout_height="40dip" />

これをチェックすると、完全にスクロールしても下部にボタンが表示されます。

于 2012-07-25T06:54:11.753 に答える