我使用 android:rotation="180" 使滑动抽屉水平显示在屏幕左侧。它工作正常。但是,由于旋转,内容在其中出现颠倒。我也尝试旋转内容布局,但只有在滑动抽屉完全打开后才会旋转。请检查我随附的代码。
MainActivity.java
public class MainActivity extends Activity {
ArrayAdapter<String> myAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView LV = (ListView) findViewById(R.id.listView1);
String [] List = {"item 1","item 2","item 3","item 4"};
myAdapter = new ArrayAdapter<String>(this, R.layout.list_item, R.id.textView1, List);
LV.setAdapter(myAdapter);
}
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
<SlidingDrawer
android:id="@+id/slidingDrawer1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:content="@+id/listView1"
android:handle="@+id/handle"
android:orientation="horizontal"
android:rotation="180" >
<Button
android:id="@+id/handle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Handle" />
<ListView
android:id="@+id/listView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:rotation="180"
tools:listitem="@layout/list_item" >
</ListView>
</SlidingDrawer>
list_item.xml
<?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:orientation="horizontal" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="10dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>