Android 安卓图像按钮被剪掉了

Android 安卓图像按钮被剪掉了,android,android-layout,android-linearlayout,android-imagebutton,Android,Android Layout,Android Linearlayout,Android Imagebutton,我的活动和其中的ImageButton有问题。它看起来像是在剪辑: 这是相应活动的XML: <?xml version="1.0" encoding="utf-8"?> <!-- A RecyclerView with some commonly used attributes --> <LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="ma

我的活动和其中的ImageButton有问题。它看起来像是在剪辑:

这是相应活动的XML:

<?xml version="1.0" encoding="utf-8"?>
<!-- A RecyclerView with some commonly used attributes -->
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:id="@+id/todo_linear_layout"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:orientation="horizontal">

    <ImageButton
        android:id="@+id/imageButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:adjustViewBounds="true"
        app:srcCompat="@android:drawable/ic_input_add" />

    <EditText
        android:id="@+id/edittodo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20px"
        android:layout_weight="5"
        android:textColor="@android:color/black" />
</LinearLayout>

<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/todo_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" >

</android.support.v7.widget.RecyclerView>
</LinearLayout>


问题出在哪里?我已经尝试更改边距或填充值,但该按钮仍在我的android设备上运行的应用程序中剪切。

我相信发生的情况是,您运行应用程序的设备没有
@android:drawable/ic\u input\u add
drawable

我试着运行你发布的代码,一切都对我有用。但是,如果我从
标记中删除
app:srcCompat
属性,那么我会得到与您在第一个屏幕截图中发布的相同的行为

一般来说,你不能100%依赖拥有
@android:
资源的设备。一些制造商删除了资源,而另一些制造商则用废话替换了这些值(例如,我看到
@android:color/white
变成了灰色)

我建议您创建自己的drawable(甚至可以从Android手动复制一个并将其添加到您的项目中),并引用它

app:srcCompat="@drawable/your_own_add"

将app:srcCompat更改为:
android:src=“@android:drawable/ic\u input\u add”
成功了!所以问题是,设备没有找到该图标,只是显示了一些灰色。

您使用的是vector right for image inside ImageButton?我尝试时效果很好。您是否尝试过将srcCompat设置为ic\u input\u add之外的其他值?这真的很奇怪,因为这个图标是从最早的android开始出现的version@nupadhyaya是的。例如,我尝试使用另一个加号(我不知道atm的确切名称)@NKnuelle尝试给线性布局赋予高度,或者使用android:src而不是app:src。这似乎是问题所在。我明天试试看。我从未想过,android资源不能出现在android设备上。这听起来很奇怪