在我的佈局文件中,對於最後一個線性佈局,我添加了三個帶有有效圖像和文本的圖像按鈕。但是他們根本沒有在應用程序中顯示。下面給出了這個佈局文件。沒有在imageButtons中獲取圖像
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="120dp"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/female_default"
android:layout_gravity="center_horizontal"
android:id="@+id/imageView2"
android:layout_weight="1" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:text="TextView"
android:layout_gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView3" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="TextView"
android:layout_gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView2" />
<TextView
android:id="@+id/id"
android:layout_gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:text="Balle"
android:textAppearance="?attr/textAppearanceListItem" />
<TextView
android:id="@+id/content"
android:layout_gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:text="Shaaba"
android:textAppearance="?attr/textAppearanceListItem" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="100dp">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:srcCompat="@android:drawable/ic_menu_edit"
android:id="@+id/imageButton4"
android:layout_weight=".25" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:srcCompat="@android:drawable/ic_menu_delete"
android:id="@+id/imageButton3"
android:layout_weight=".25" />
<Button
android:text="@string/mark_as_default"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/button"
android:layout_weight=".5" />
</LinearLayout>
</LinearLayout>
即使在這些變化之後它仍然不工作:( –
使用android:src而不是android:srcCompat並重試。 –