有没有人得到的支持库在Android的2正确显示网格布局?而不是2行和列,我得到一个单列在屏幕上看到的logcat输出这个错误: Android的网格布局找不到方法android.support.v7.widget.ViewGroup.onChildVisibilityChanged
完全相同的布局正在Android4 - > ICS当我改变从布局标签 android.support.v7.widget.GridLayout到网格布局
难道这是有些问题的设置?我有gridlayout_v7库项目在我的Eclipse项目属性Android的选项卡,第13节罐子构建路径上。
在XML布局失败下面粘贴。我增加了布局的行和列明确的图像按钮标签,以努力解决该问题。如果任何人有一个在Android 2的支持库运行工作示例,请分享。如果你有工作,我会AP preciate你帮忙找我去。 感谢和问候!
< android.support.v7.widget.GridLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:列数=2安卓rowCount时=2
机器人:重力=center_vertical
机器人:布局=@可绘制/ bg_test_main>
< ImageButton的机器人:ID =@ + ID / btnSentence
机器人:layout_row =0
机器人:layout_column =0
机器人:SRC =@可绘制/ testa_btn
机器人:contentDescription =@字符串/ spin_fill_in
机器人:背景=@机器人:彩色/透明
/>
< ImageButton的机器人:ID =@ + ID / btnAudio
机器人:layout_row =0
机器人:layout_column =1
机器人:SRC =@可绘制/ testb_btn
机器人:contentDescription =@字符串/ audio_quiz
机器人:背景=@机器人:彩色/透明
/>
< ImageButton的机器人:ID =@ + ID / btnPickWord
机器人:layout_row =1
机器人:layout_column =0
机器人:SRC =@可绘制/ testc_btn
机器人:背景=@机器人:彩色/透明
机器人:contentDescription =@字符串/ def_pick_word/>
< ImageButton的机器人:ID =@ + ID / btnPickDef
机器人:layout_row =1
机器人:layout_column =1
机器人:SRC =@可绘制/ testd_btn
机器人:背景=@机器人:彩色/透明
机器人:contentDescription =@字符串/ pick_def/>
< /android.support.v7.widget.GridLayout>
解决方案
我猜你错过了添加XML命名空间。请它纠正了这种方式:
< android.support.v7.widget.GridLayout
的xmlns:格=http://schemas.android.com/apk/res-auto
的xmlns:机器人=http://schemas.android.com/apk/res/android>
...
< /android.support.v7.widget.GridLayout>
和不要忘了与XML命名空间也使用兼容网格布局preFIX属性:
< ImageButton的机器人:ID =@ + ID / btnSentence
格:layout_row =0
格:layout_column =0
...
/>
希望它可以帮助...
Has anybody gotten the support library to render a grid layout correctly in Android 2? Instead of 2 rows and columns I get a single row on the screen and see this error in the logcat output: Android GridLayout Could not find method android.support.v7.widget.ViewGroup.onChildVisibilityChanged
The same exact layout is working on Android4 -> ICS when I change the layout tag from android.support.v7.widget.GridLayout to GridLayout
Could this be some issue with the setup? I have the gridlayout_v7 library project in the Android tab of my Eclipse project properties and the v.13 jar is on the build path.
The xml layout that is failing is pasted below. I added the layout rows and columns explicitly in the image button tags in an effort to work around the problem. If anybody has a working example that runs on Android 2 with the support library, please share. If you have it working, I would appreciate your help to get mine going. Thanks and regards!
<android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="2" android:rowCount="2"
android:gravity="center_vertical"
android:layout="@drawable/bg_test_main" >
<ImageButton android:id="@+id/btnSentence"
android:layout_row="0"
android:layout_column="0"
android:src="@drawable/testa_btn"
android:contentDescription="@string/spin_fill_in"
android:background="@android:color/transparent"
/>
<ImageButton android:id="@+id/btnAudio"
android:layout_row="0"
android:layout_column="1"
android:src="@drawable/testb_btn"
android:contentDescription="@string/audio_quiz"
android:background="@android:color/transparent"
/>
<ImageButton android:id="@+id/btnPickWord"
android:layout_row="1"
android:layout_column="0"
android:src="@drawable/testc_btn"
android:background="@android:color/transparent"
android:contentDescription="@string/def_pick_word" />
<ImageButton android:id="@+id/btnPickDef"
android:layout_row="1"
android:layout_column="1"
android:src="@drawable/testd_btn"
android:background="@android:color/transparent"
android:contentDescription="@string/pick_def" />
</android.support.v7.widget.GridLayout>
解决方案
I guess you missed to add XML namespace. Please correct it in this way:
<android.support.v7.widget.GridLayout
xmlns:grid="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
...
</android.support.v7.widget.GridLayout>
and don't forget to prefix attributes used by compatibility GridLayout with XML namespace too:
<ImageButton android:id="@+id/btnSentence"
grid:layout_row="0"
grid:layout_column="0"
...
/>
Hope it helps...