디자이너 미리보기에서 이미지를 볼 수 있지만 Android ImageButton은 이미지를 표시하지 않습니다.

머리 :

Android Studio에서 이미지 버튼을 만들려고합니다. Designer 미리보기에는 이미지가 올바르게 표시되지만 앱을 실행하면 버튼에 이미지가 없습니다. 빈 버튼은 가능한 한 작습니다.

내가 시도한 것 :

  • Android 드로어 블 폴더에서 내 드로어 블 폴더로 이미지 복사
  • 일부 소스에 따르면 버그로 인해 자리 표시 자 이미지를 만들면 폴더의 첫 번째 이미지가 표시되지 않습니다.
  • 다른 이미지 사용

이 중 어느 것도 나를 위해 일하지 않았습니다. 전체 기능이 고장난 것 같습니다. 흥미로운 부분은 이미지를 설정할 때 이미지 버튼의 배경으로 작동한다는 것입니다. 그러나 그것은 "버튼 모양"을 잃어 버렸으므로 나에게는 해결책이 아닙니다.

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

<org.osmdroid.views.MapView android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<LinearLayout
    android:id="@+id/search_ui"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    android:padding="1dp"
    android:background="@color/white"
    android:orientation="horizontal">
    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@drawable/ic_menu_manage"
        android:id="@+id/imageButton"/>
    <EditText android:id="@+id/edit_search_string"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:hint="@string/search_string" />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_send"
        android:onClick="myClickHandler"/>
</LinearLayout>

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="5dp"
    android:background="@color/white"
    android:layout_below="@id/search_ui">
    <TextView
        android:id="@+id/display"
        android:textSize="16sp"
        android:textStyle="bold"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="New Text" />
</LinearLayout>

쿠날 파리 크 :

srcCompat 대신 src 만 사용하고 작동하는지 확인하십시오.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

TOP 리스트

뜨겁다태그

보관