我使用了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>
答案 0 :(得分:3)
我已经实现了SlidingDrawer组件的完全替换,它可以从任何方向/方向工作。有关详细信息,请参阅http://www.github.com/kedzie/DraggableDrawers。
现在可以从Maven Central(maven-android-plugin)获得:
<dependency>
<groupid>com.github.kedzie.draggabledrawers</groupId>
<artifactId>library</artifactId>
<version>1.0.0</version>
<type>apklib</type>
</dependency>
答案 1 :(得分:1)
请查看THIS教程。你不需要旋转抽屉......
答案 2 :(得分:-2)
尝试使用android:gravity="left"
代替轮换