2017-07-19 56 views
0

在android studio中,我已经在相对布局中添加了一个ButtonView。虽然在预览中没有问题,但它在播放时不会出现。播放时图像按钮显示不正确

代码:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.xxx.xxx.xxx" 
    android:orientation="vertical" 
    android:weightSum="1" 
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
    > 

    <WebView 
     android:id="@+id/webV" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true"> 

    </WebView> 

    <ImageButton 
     android:id="@+id/imageButton7" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     app:srcCompat="@mipmap/ic_gear" /> 
</RelativeLayout> 
+0

提示(*常见的错误使用'mipmap's *):请注意,'mipmap'文件夹仅用于保存**启动器图标**。 –

+0

然后,我应该在哪里将我的装备图像放在任何单独的文件夹或具有特定名称的文件夹中? – pepito

+0

在一个具体的名称:'drawable'(drawable-xyzdpi,实际上) –

回答

0

添加android:layout_below="@+id/webV"ImageButton

<ImageButton 
    android:id="@+id/imageButton7" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/webV" 
    app:srcCompat="@mipmap/ic_gear" /> 
0

这是很奇怪的,但如果你使用安卓背景代替应用:srcCompat,它可能工作

<ImageButton 
      android:id="@+id/imageButton7" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@mipmap/ic_gear" />