我正在爲平板電腦和移動設備創建演示應用程序。
現在有一個活動有兩個tabs
,所以裏面的標籤有ListView
。
我的問題是我想從左側和右側顯示ListView
一些邊距。因此,作爲方向更改,邊距值也發生變化
我已根據以下內容從developer side中閱讀文檔以下是代碼片段的listview。
內res/layout-xlarge-land
文件夾如何根據平板電腦的方向定位佈局
<ListView
android:id="@+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="250dp"
android:layout_marginRight="250dp" >
</ListView>
內res/layout-xlarge-port
文件夾
<ListView
android:id="@+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:layout_marginRight="100dp" >
</ListView>
現在的問題是,當我改變平板電腦的方向,只需要縱向模式的XML文件,而不是景觀xml文件。那麼如何解決這個問題。
也包括在manifeast文件<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="17" />
<supports-screens android:anyDensity="true" android:resizeable="true"/>
和活動包括android:configChanges="orientation|screenSize"
如果我刪除,因爲你提到的應用程序崩潰,因爲方向改變.. – Pravin 2013-04-23 13:18:21
該活動應該被銷燬和重新創建。如果你不想這樣做,那麼你必須重寫'onConfigurationChanged(Configuration newConfig)'並再次使用相同的佈局設置內容視圖,你將需要更新任何對視圖的引用,因爲它們都將被替換 – ScouseChris 2013-04-23 13:21:03