There are any was to use Glide with Button's background image?
I tried with code below, but get error for into(building1Button)
"cannot resolve method 'into(android.widget.Button)'
Can somebody help me how to use glide with button background image?
xml code:
<Button
android:id="#+id/building1Button"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="5dp"
android:background="#drawable/building1pintest"
android:onClick="openbuildings1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.109"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
mainactivity:
Button building1Button;
....
...
..
....onCreate.....
building1Button = findViewById(R.id.building1Button);
Glide.with(this).load(R.drawable.building1pintest).into(building1Button);
Related
I'm Using circulcar image view libary available on github. I also add it to build.gradle and sync it. but i am still not getting circular image. if I add SRC insted of background, still not getting result. where i am wrong?
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/imageView"
android:layout_width="200dp"
android:layout_height="200dp"
android:background="#drawable/splash_screen"
app:civ_border_width="10dp"
app:civ_border_color="#FF000000"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView" />
remove this line : android:background="#drawable/splash_screen"
and Add this line : android:src="#drawable/splash_screen"
Just change the background line. It will show the circular image.
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/imageView"
android:layout_width="200dp"
android:src="#drawable/splash_screen"
android:layout_height="200dp"
app:civ_border_width="10dp"
app:civ_border_color="#FF000000"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView" />
Image was displayed to the background that's why it was showing the square.
i have application with android java but now i want to convert into flutter but problem is how i can use
android:scaleType="fitCenter"
in image view.
here is my image view code can anyone help me out?
<ImageView
android:id="#+id/imgView2"
android:layout_width="112dp"
android:layout_height="150dp"
android:background="#000000"
android:contentDescription="TODO"
android:padding="1dp"
android:scaleType="fitCenter"
android:src="#android:drawable/editbox_dropdown_dark_frame"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.501"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.528" />
Flutter has a fit property in Image widget which is equivalent to scaleType which accepts Boxfit enum values. You can see more about Image widget here.
In my Android app with kotlin, I want to display a user image in the middle AppBar.
The following code is For circular Image :
<com.mikhaellopez.circularimageview.CircularImageView
android:id="#+id/userImage"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginStart="133dp"
android:layout_marginTop="135dp"
android:layout_marginEnd="134dp"
android:layout_marginBottom="14dp"
android:src="#drawable/userprofil"
app:civ_border="true"
app:civ_border_width="2dp"
app:civ_shadow="true"
app:civ_shadow_radius="0"
app:layout_anchor="#id/app_bar_layout"
app:layout_anchorGravity="bottom|center"
app:layout_constraintBottom_toTopOf="#+id/textViewUserName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/app_bar_layout" />
I want a result like this :
But, I get the following result :
What should I change to get the result
The app bar by default has an elevation of 8 dp. So if you are adding any views overlapping with them without adding elevation then they will stay hidden behind the app bar. You need to add elevation more then 8dp on your imageview like below
<com.mikhaellopez.circularimageview.CircularImageView
android:id="#+id/userImage"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginStart="133dp"
android:layout_marginTop="135dp"
android:layout_marginEnd="134dp"
android:layout_marginBottom="14dp"
android:src="#drawable/userprofil"
android:elevation="10dp" // Add this line
app:civ_border="true"
app:civ_border_width="2dp"
app:civ_shadow="true"
app:civ_shadow_radius="0"
app:layout_anchor="#id/app_bar_layout"
app:layout_anchorGravity="bottom|center"
app:layout_constraintBottom_toTopOf="#+id/textViewUserName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/app_bar_layout" />
Just put "translationZ" property in your imageview. so image view comes in front
I want to create user profile. I am using Firebase to make authentication and get profile picture but when I get profile picture, quality is not good.
I used Glide to load image
Glide.with(this)
.load(this.getCurrentUser().getPhotoUrl())
.apply(RequestOptions.circleCropTransform())
.into(imageViewProfile);
My Image view:
<ImageView
android:id="#+id/imageView"
android:layout_width="113dp"
android:layout_height="102dp"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="8dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
How can I fix it? I already try to use Picasso but that didn't work.
Instead of using RequestOptions.circleCropTransform(), try using CircleImageView.
Import this -
compile "de.hdodenhof:circleimageview:2.1.0"
in your layout file
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="#dimen/_80sdp"
android:layout_height="#dimen/_80sdp"
android:layout_centerHorizontal="true"
android:id="#+id/prof_pic"
app:civ_border_width="#dimen/_2sdp"
app:civ_border_color="#bf0000"
android:elevation="#dimen/_2sdp"
android:layout_marginTop="#dimen/_60sdp"
/>
and to load image
Glide.with(getActivity()).load("url").placeholder(R.drawable.bluehead).into(Prof_Pic);
The app crashes when I try to load an image with Glide.
I have the following code:
.java:
ImageButton home_ib1;
Glide.with(Home.this)
.load(R.drawable.moviep_24_hours_to_live)
.override(98, 155)
.centerCrop()
.placeholder(R.drawable.moviep_24_hours_to_live)
.into(home_ib1);
.xml:
<ScrollView
<RelativeLayout
<ImageButton
android:id="#+id/home_ib1"
android:layout_width="98dp"
android:layout_height="155dp"
android:layout_marginStart="16dp"
android:layout_marginTop="155dp"
android:background="#android:color/transparent"
android:scaleType="fitCenter"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
And when I try to run app, i got crash..(LogCat: You must pass in a non null View)
(The image's resolution that i have to load is 175x276 PNG)
ImageButton home_ib1;
Looks Like home_ib1 is null
Just add
home_ib1 = findViewById(R.id.home_ib1);