Issue
I'm working on an Android App. In a fragment, I need to put some buttons with text and images. I use drawableStart attribute to put a drawable. Any ideas about it does not display images?
Just another information: my project is using JetPack libraries (latest version).
The layout code:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:clipChildren="false"
android:fillViewport="true"
app:behavior_overlapTop="128dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".ui.activities.DocumentoDetailActivity"
tools:showIn="@layout/activity_documento_detail">
<androidx.cardview.widget.CardView
android:id="@+id/documento_card"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginLeft="@dimen/text_margin"
android:layout_marginTop="32dp"
android:layout_marginRight="@dimen/text_margin"
android:layout_marginBottom="@dimen/text_margin"
android:transitionName="@{@string/event_card_transition + eventDetailViewModel.event.id}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/documento_image_thumbnail"
android:layout_width="58dp"
android:layout_height="0dp"
android:background="@android:color/darker_gray"
android:contentDescription="@string/app_img_content_description"
android:cropToPadding="true"
android:elevation="@dimen/app_cardview_default_elevation"
android:scaleType="centerCrop"
app:layout_constraintDimensionRatio="W,4:3"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/ic_thumbnail_laboratorio_analisi" />
<!--app:loadUrl="@{eventDetailViewModel.event.thumbnail}"-->
<!--android:transitionName="@{@string/event_image_transition + eventDetailViewModel.event.id}"-->
<!--<androidx.cardview.widget.CardView-->
<!--android:id="@+id/documento_preferred"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_marginTop="8dp"-->
<!--android:layout_marginEnd="8dp"-->
<!--android:transitionGroup="true"-->
<!--android:visibility="visible"-->
<!--app:cardBackgroundColor="#FFFFFF"-->
<!--app:cardElevation="@dimen/app_design_appbar_elevation"-->
<!--app:layout_constraintEnd_toEndOf="@+id/documento_card"-->
<!--app:layout_constraintRight_toRightOf="@id/documento_card"-->
<!--app:layout_constraintTop_toTopOf="@+id/documento_card">-->
<!--<ImageView-->
<!--android:id="@+id/documento_star"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_marginStart="8dp"-->
<!--android:layout_marginTop="8dp"-->
<!--android:layout_marginEnd="8dp"-->
<!--android:layout_marginBottom="8dp"-->
<!--app:srcCompat="@drawable/ic_item_unstarred" />-->
<!--android:text="@{eventDetailViewModel.event.price}"-->
<!--</androidx.cardview.widget.CardView>-->
<TextView
android:id="@+id/documento_titolo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:elevation="@dimen/app_cardview_default_elevation"
android:ellipsize="end"
android:maxLines="3"
android:textAppearance="@style/TextAppearance.AppCompat.Title"
android:transitionName="@{@string/event_name_transition + eventDetailViewModel.event.id}"
app:layout_constraintLeft_toRightOf="@id/documento_image_thumbnail"
app:layout_constraintStart_toEndOf="@+id/documento_image_thumbnail"
app:layout_constraintTop_toTopOf="@+id/documento_card"
tools:text="@sample/documenti.json/data/titolo" />
<!--android:text="@{eventDetailViewModel.event.name}"-->
<TextView
android:id="@+id/documento_info1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:layout_marginEnd="8dp"
android:elevation="@dimen/app_cardview_default_elevation"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textColor="@color/primary_dark"
app:layout_constraintEnd_toEndOf="@+id/documento_card"
app:layout_constraintStart_toEndOf="@+id/documento_info1_label"
app:layout_constraintTop_toBottomOf="@+id/documento_titolo"
tools:text="@sample/documenti.json/data/info" />
<!--android:text="@{eventDetailViewModel.venue.name}"-->
<TextView
android:id="@+id/documento_info1_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:elevation="@dimen/app_cardview_default_elevation"
android:text="Data:"
app:layout_constraintStart_toEndOf="@+id/documento_image_thumbnail"
app:layout_constraintTop_toBottomOf="@+id/documento_titolo" />
<Button
android:id="@+id/documento_btn_cancella"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:elevation="@dimen/app_cardview_default_elevation"
android:text="@string/documento_cancella"
android:drawableStart="@drawable/ic_action_delete_24dp"
app:layout_constraintStart_toStartOf="@+id/documento_card"
app:layout_constraintTop_toBottomOf="@+id/documento_info1" />
<Button
android:id="@+id/documento_btn_modifica"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:elevation="@dimen/app_cardview_default_elevation"
android:text="@string/documento_modifica"
android:drawableStart="@drawable/ic_action_delete_24dp"
app:layout_constraintEnd_toStartOf="@+id/documento_btn_vedi"
app:layout_constraintStart_toEndOf="@+id/documento_btn_cancella"
app:layout_constraintTop_toBottomOf="@+id/documento_info1" />
<Button
android:id="@+id/documento_btn_vedi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:layout_marginEnd="8dp"
android:elevation="@dimen/app_cardview_default_elevation"
android:text="@string/documento_vedi"
android:drawableStart="@drawable/ic_action_search__white_24dp"
app:layout_constraintEnd_toEndOf="@+id/documento_card"
app:layout_constraintTop_toBottomOf="@+id/documento_info1" />
<!--android:rating="@{eventRatingViewModel.result.rating}"-->
<androidx.viewpager.widget.ViewPager
android:id="@+id/documento_view_pager"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginLeft="@dimen/text_margin"
android:layout_marginTop="8dp"
android:layout_marginRight="@dimen/text_margin"
android:layout_marginBottom="@dimen/text_margin"
android:elevation="4dp"
android:transitionGroup="true"
app:layout_constraintBottom_toBottomOf="@id/documento_card"
app:layout_constraintLeft_toLeftOf="@id/documento_card"
app:layout_constraintRight_toRightOf="@id/documento_card"
app:layout_constraintTop_toBottomOf="@+id/documento_btn_vedi">
<!--app:pageMargin="@{@dimen/activity_horizontal_margin}}"-->
<!--app:sectionAdapter="@{eventDetailViewModel.event.id}"-->
<!--app:pageMargin="@dimen/activity_horizontal_margin"-->
<com.google.android.material.tabs.TabLayout
android:id="@+id/documento_tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabTextAppearance="@style/AppTabLayoutStyle"
/>
<!--app:setupWithViewPager="@{viewPager}"-->
</androidx.viewpager.widget.ViewPager>
</androidx.constraintlayout.widget.ConstraintLayout>
<!--</layout>-->
Thank you in advance!
Solution
I finally found. I wrote here to share my solution. I resolved using app:icon
attribute instead of android:drawableStart
.
Answered By - xcesco
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.