2

Android フォンを potrait から landscpe に変更すると、リスト ビューのすべてのリスト アイテムのサイズが変更されます。ListView が正しく更新されません。リストビューの幅は、向きの変更時に親を埋めません。アクティビティのマニフェスト ファイルでconfigChanges:orientationを試しましたが、結果は同じです。

画像を以下に示します。

肖像:

ここに画像の説明を入力

風景:

ここに画像の説明を入力

行全体が向きの変更に合わせてサイズ変更されています。

以下に、使用されるxmlレイアウトを示します。

 <LinearLayout

        a:id="@+id/web_watch_list_modifier_row_body"
        a:visibility="visible"
        a:gravity="center"
        a:background="@drawable/list_selector"
        a:layout_height="wrap_content"
        a:layout_width="fill_parent"
        a:orientation="horizontal">

    <EditText
            a:id="@+id/watch_list_name_text_box"
            a:layout_height="40dip"
            a:layout_width="0dip"
             a:layout_marginLeft="2dp"
            a:maxLength="32"
            a:singleLine="true"
            a:layout_weight="40"/>


    <ImageView
            a:id="@+id/dragImageView"
            a:background="@drawable/drag_button_img"
            a:layout_height="wrap_content"
            a:layout_width="wrap_content"/>

</LinearLayout>

あなたの貴重な提案を待っています...

4

2 に答える 2

0

デバイスを回転させるたびに、アクティビティが再起動します..それが EditText のサイズが変更される理由かもしれません.

これをマニフェストファイルに追加してみてください。

android:configChanges="orientation|keyboardHidden"

これもhttp://developer.android.com/guide/topics/resources/runtime-changes.htmlで確認できます。

于 2013-04-01T15:19:04.300 に答える
0

a:layout_width または LinearLayout を「match_parent」に変更することから始めます。他の要素に重みがない場合、layout_weight="40" が何を達成するかわかりません。1 を試してください。

代わりに、次のように RelativeLayout を試してみます (xml の正確性をチェックしませんでした)。

<RelativeLayout
        a:id="@+id/web_watch_list_modifier_row_body"
        a:background="@drawable/list_selector"
        a:layout_height="wrap_content"
        a:layout_width="match_parent" >

    <EditText
            a:id="@+id/watch_list_name_text_box"
            a:layout_height="40dip"
            a:layout_width="0dip"
            a:layout_marginLeft="2dp"
            a:maxLength="32"
            a:singleLine="true"
            a:layout_alignParentLeft="true"

            />


    <ImageView
            a:id="@+id/dragImageView"
            a:background="@drawable/drag_button_img"
            a:layout_height="wrap_content"
            a:layout_width="wrap_content"
            a:layout_alignParentRight="true"
            a:layout_toLeftOf="@id/watch_list_name_text_box" />

</RelativeLayout>

android:configChanges を宣言しないと、方向を変更したときにアクティビティが再起動されます。必要なのは、新しい方向に合わせたレイアウトだけである場合は望ましくありません。

重要:ターゲット バージョンが 13 以降の場合は、「screenSize」android:configChanges="orientation|screenSize" http://developer.android.com/guide/topics/manifest/activity-element.html#も宣言する必要があります。構成

それでもうまくいかない場合は、onConfigurationChanged() をオーバーライドして、ListView を無効にしてみてください。

于 2013-04-01T12:29:59.157 に答える