0

フッター付きのリストビューを含むレイアウトがあります。このフッターをプログラムで追加します。横向きモードを使用したいので、すべてを行いましたが、問題があります。

portiet モードのフッターは、親の幅を埋めます。しかし、ランドスケープに変更すると、ラップコンテンツになります。

助けてください。

これは、プログラムでフッターを追加する方法です

View footer = LayoutInflater.from(this).inflate(R.layout.footer_button,
                null);
        footer.setPadding(0, 0, 0, 0);

ランドスケープレイアウト

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/tv_customer_profile_title"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip"
        android:gravity="center"
        android:text="@string/tv_name"
        android:textColor="#025f7c"
        android:textSize="30sp"
        android:typeface="serif" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:paddingTop="15dip" >

        <ImageView
            android:id="@+id/iv_customer_profile_image"
            android:layout_width="0dip"
            android:layout_height="150dip"
            android:layout_weight="1"
            android:contentDescription="@string/iv_undefinedImage"
            android:paddingLeft="5dip"
            android:src="@drawable/totti" />

        <ListView
            android:id="@+id/lv_customer_profile_details"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:cacheColorHint="#00000000"
            android:paddingLeft="10dip"
            android:paddingRight="10dip" >
        </ListView>
    </LinearLayout>

</LinearLayout>
4

2 に答える 2

1

ここにある同様の解決策を試すことができます:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_layout);
    ViewGroup parent = (ViewGroup) findViewById(R.id.host_layout);
    View footer = LayoutInflater.from(this).inflate(R.layout.footer_button, null);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
        ViewGroup.LayoutParams.FILL_PARENT,
        ViewGroup.LayoutParams.FILL_PARENT); 
    parent.addView(view, params);
}

編集:

を見てみると、には が含まれており、 には次のようなものがxmlあることに気付きました。LinearLayoutImageViewListView

android:layout_height="wrap_content"

私の理解が正しければ、これはフッター ボタンを含むレイアウトで、縦向きでは fill_parent のように見えるかもしれませんが、大きな画面で見てみてください。

于 2013-07-03T10:56:55.963 に答える
0

ビューのレイアウト パラメータを手動で設定して、その幅が fill_parent に設定されていることを確認してください。

于 2013-07-03T10:51:49.750 に答える