Android 某个png图像从布局中消失
我有一个布局xml,它有16个图像按钮 在该布局中声明的一个png图像不会显示在活动中。(仅android 2.2/2.3) 当我在drawable中添加虚拟图像时,奇怪的是,前面的图像将消失。 (当出现两个虚拟图像时,图像前两个将消失…) 在eclipse图形布局中,我可以在android手机上看到消失的图像 我已经检查过R文件中有一个消失图像的声明。 有人知道这个问题的进展吗 我将感谢你的支持 例如在下面的代码中。。。 标签为3的ImageButton不显示在屏幕上,甚至不可单击。 但当我添加虚拟按钮(如按钮999)时,它实际上并没有在应用程序中使用,然后带有标记2的ImageButton消失了,而带有标记3的ImageButton这次显示出来。 如果我再添加一个伪按钮,如按钮998,则带有tag1的ImageButton将消失 这是款式Android 某个png图像从布局中消失,android,layout,png,imagebutton,Android,Layout,Png,Imagebutton,我有一个布局xml,它有16个图像按钮 在该布局中声明的一个png图像不会显示在活动中。(仅android 2.2/2.3) 当我在drawable中添加虚拟图像时,奇怪的是,前面的图像将消失。 (当出现两个虚拟图像时,图像前两个将消失…) 在eclipse图形布局中,我可以在android手机上看到消失的图像 我已经检查过R文件中有一个消失图像的声明。 有人知道这个问题的进展吗 我将感谢你的支持 例如在下面的代码中。。。 标签为3的ImageButton不显示在屏幕上,甚至不可单击。 但当我添
<style name="layoutStyle">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:orientation">horizontal</item>
<item name="android:layout_marginRight">3dip</item>
<item name="android:layout_marginLeft">3dip</item>
<item name="android:baselineAligned">false</item>
</style>
<style name="buttonStyle">
<item name="android:layout_width">0dip</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">1</item>
<item name="android:adjustViewBounds">true</item>
<item name="android:background">#00000000</item>
<item name="android:scaleType">centerInside</item>
<item name="android:padding">2dip</item>
<item name="android:onClick">onClick</item>
</style>
填补家长的空缺
包装内容
水平的
3dip
3dip
假的
0度
包装内容
1.
真的
#00000000
中心内
2dip
onClick
和布局文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
style="@style/layoutStyle"
android:layout_marginTop="8dip">
<ImageButton
style="@style/buttonStyle"
android:tag="1"
android:contentDescription="@string/contentDescription"
android:src="@drawable/button_selector_1"/>
<ImageButton
style="@style/buttonStyle"
android:tag="2"
android:contentDescription="@string/contentDescription"
android:src="@drawable/button_selector_2"/>
<ImageButton
style="@style/buttonStyle"
android:tag="3"
android:contentDescription="@string/contentDescription"
android:src="@drawable/button_selector_3"/>
<LinearLayout
style="@style/layoutStyle"
android:layout_marginTop="8dip">
<ImageButton
style="@style/buttonStyle"
android:tag="4"
android:contentDescription="@string/contentDescription"
android:src="@drawable/button_selector_5"/>
<ImageButton
style="@style/buttonStyle"
android:tag="5"
android:contentDescription="@string/contentDescription"
android:src="@drawable/button_selector_4"/>
<ImageButton
style="@style/buttonStyle"
android:tag="6"
android:contentDescription="@string/contentDescription"
android:src="@drawable/button_selector_6"/>
…… and so on(total 6 child layout)
</LinearLayout>
……等等(共6个子布局)
清理项目,然后重试您使用哪种代码为按钮分配图像
您是分配动态图像还是静态图像
如果您使用的是静态图像,请将图像存储在Drawable文件夹中并清理项目。
然后为每个按钮指定图像,如下所示
<Button
android:id="@+id/button1"
android:layout_width="wrapcontent"
android:layout_height="wrapcontent"
android:background="@drawable/img1"
android:text="Button" />
粘贴布局文件。我添加了代码。知道吗?用静态图像。这已经存储在drawable文件夹中。将你的代码粘贴到你的问题中,这样我们才能清楚地讨论。我只是添加了代码和简单的解释。请看一看。