I created a action bar in xml for use in all activities. I used the include
tag for it.
One of my activities have just a GridView
tag. you can see it's source below:
<?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>
It doesn't have any problem but when I add the include
tag or any other tag to this (similar below source)
<?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" >
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
layout="@layout/action_bar" />
<GridView
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>
It doesn't give me an error but the GridView
is hidden when the activity appears. Is there a solution for this problem?
but the gridview is hidden when activity apear. it there ant solution for it? thanks.
You may want to either set the orientation of the LinearLayout
to vertical so your included layout doesn't push the GridView
outside of the screen on the right or you could use wrap_content
for the included layout's width. Using the orientation change:
<?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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.