我在VideoView的顶部有一个透明的ListView,但现在这些行占据了整个屏幕的宽度。我想知道是否有办法减少这个。我的XML看起来像这样:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeScreen"
android:descendantFocusability="blocksDescendants"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<VideoView
android:id="@+id/VideoWindow"
android:descendantFocusability="blocksDescendants"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
</VideoView>
<TextView
android:id="@android:id/list"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</TextView>
</RelativeLayout>
Java代码是:
setListAdapter(new ArrayAdapter<String>(this, R.layout.main, android.R.id.list, a_list));
// Get an object for the list
ListView listView = getListView();
listView.setTextFilterEnabled(true);
listView.setCacheColorHint(0);
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
InitiatePlayback(position);
}
});
答案 0 :(得分:0)
而不是将textview宽度和高度设置为match_parent设置为wrap_content。
<TextView
android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
答案 1 :(得分:0)
// try this
<?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:padding="5dp"
android:orientation="vertical">
<ListView
android:layout_height="0dp"
android:layout_weight="0.75"
android:layout_width="match_parent"
android:cacheColorHint="#00000000"
android:divider="@null"
android:dividerHeight="0dp"
android:smoothScrollbar="true"
android:id="@+id/listView"/>
<LinearLayout
android:layout_height="0dp"
android:layout_weight="0.25"
android:gravity="center"
android:layout_width="match_parent">
<VideoView
android:id="@+id/VideoWindow"
android:descendantFocusability="blocksDescendants"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1">
</VideoView>
<TextView
android:id="@android:id/list"
android:orientation="vertical"
android:layout_width="wrap_content"
android:text="textview"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</LinearLayout>