Android 对已存在的GridView使用include标记
我用xml创建了一个用于所有活动的操作栏。我为它使用了Android 对已存在的GridView使用include标记,android,android-layout,user-interface,Android,Android Layout,User Interface,我用xml创建了一个用于所有活动的操作栏。我为它使用了include标记。 我的一个活动只有一个GridView标记。您可以在下面看到它的来源: <?xml version="1.0" encoding="utf-8"?> <GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gv_level" android:layout_width="fil
include
标记。我的一个活动只有一个
GridView
标记。您可以在下面看到它的来源:
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gv_level"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/background_gradient"
android:columnWidth="100dp"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="columnWidth" >
</GridView>
它没有给我一个错误,但是当活动出现时,GridView
被隐藏。
这个问题有解决办法吗
但当活动启动时,gridview被隐藏。这是一个很好的解决方案
为了它?谢谢
您可能希望将线性布局的方向设置为垂直,以便所包含的布局不会将网格视图推到右侧屏幕之外,或者可以使用包裹内容
作为所包含布局的宽度。使用方向更改:
<?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="vertical" >
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
layout="@layout/action_bar" />
// ... rest of the layout
// ... 布局的其余部分
但当活动启动时,gridview被隐藏。这是一个很好的解决方案
为了它?谢谢
您可能希望将线性布局的方向设置为垂直,以便所包含的布局不会将网格视图推到右侧屏幕之外,或者可以使用包裹内容
作为所包含布局的宽度。使用方向更改:
<?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="vertical" >
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
layout="@layout/action_bar" />
// ... rest of the layout
// ... 布局的其余部分
oops。我认为默认方向是垂直的。谢谢它工作得很好。我认为默认方向是垂直的。谢谢它工作得很好。