ImageView image not showing after loading with Picaso and linking to layout file

后端 未结 4 1644
梦如初夏
梦如初夏 2021-01-26 04:09

I want to show a radio button and next to it show a ImageView with image loaded by Picaso. I tried putting the ImageView object after loading it next to the radio button in Rela

相关标签:
4条回答
  • 2021-01-26 04:25

    It seems your ImageView is overlapping over RadioGroup! It's my recommendation for activity_main.xml file: app:srcCompat="@android:drawable/sym_def_app_icon" will replace with your image .

    Try this:

    <?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:id="@+id/activity_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
       >
    
        <androidx.viewpager.widget.ViewPager
            android:id="@+id/viewPager"
            android:layout_width="match_parent"
            android:layout_height="190dp"
            android:layout_marginBottom="8dp"/>
    
    
        <RadioGroup
            android:layout_below="@id/viewPager"
            android:id="@+id/radiogroup"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
    
            <RadioButton
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Demo"/>
            <RadioButton
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Demo"/>
            <RadioButton
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Demo"/>
            <RadioButton
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Demo"/>
    
    
    
        </RadioGroup>
    
    
        <ImageView
            android:layout_marginTop="20dp"
            android:layout_below="@id/radiogroup"
            android:id="@+id/imageView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:srcCompat="@android:drawable/sym_def_app_icon"
            android:contentDescription="TODO" />
    </RelativeLayout>
    
    0 讨论(0)
  • 2021-01-26 04:27

    It seems your ImageView is overlapping over RadioGroup! It's my recommensation for activity_main.xml file:

    <?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:id="@+id/activity_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.example.test.imageslider.MainActivity">
    
        <!--<androidx.viewpager.widget.ViewPager
            android:id="@+id/viewPager"
            android:layout_width="match_parent"
            android:layout_height="190dp"
            android:layout_marginBottom="8dp"/> -->
    
    
        <RadioGroup
            android:id="@+id/radiogroup"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
    
        </RadioGroup>
    
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/myImage"
            android:layout_toEndOf="@+id/radiogroup" />
    </RelativeLayout>/>
    

    You can edit it on your own.

    Hope it works!

    P.S: I have edited activity_main.xml file out of IDE and may have some typo, so correct it if you found some :)

    0 讨论(0)
  • 2021-01-26 04:35

    Try to change your Layout because radiobutton overlaps imageview

    <LinearLayout
       android:layout_width="match_parent"
       android:layout_height="match_parent" 
       android:orientation="vertical"
    
          >
    <RadioGroup
        android:id="@+id/radiogroup"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    
    </RadioGroup>
    
    <ImageView
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:id="@+id/myImage" />
     </LinearLayout>
    
    0 讨论(0)
  • 2021-01-26 04:39

    Give height and weight to ImageView. I have tested it and works fine,

    <?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:id="@+id/activity_main"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
        <!--<androidx.viewpager.widget.ViewPager
            android:id="@+id/viewPager"
            android:layout_width="match_parent"
            android:layout_height="190dp"
            android:layout_marginBottom="8dp"/> -->
    
    
        <RadioGroup
                android:id="@+id/radiogroup"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >
    
        </RadioGroup>
    
        <ImageView
                android:id="@+id/myImage"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:layout_toEndOf="@+id/radiogroup"/>
    </RelativeLayout>
    
    0 讨论(0)
提交回复
热议问题