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.
Related
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.
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);
I have a player screen where I want to display the artwork provided by an audio file as a square. Most files provide a square artwork, but some will provide a rectangle one.
In that case, I want to use the full height of the image and 'zoom in' losing some information on the right and the left but being able to show it in a square.
Right now I failed to do so.
Also, I would like it to work as well if a vertical rectangle is provided
I'm new to Constraintlayout and try the following but that doesn't work
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:gravity="center"
android:filter="true"
android:padding="20dp"
android:elevation="1dp"
android:scaleType="centerCrop" />
</androidx.constraintlayout.widget.ConstraintLayout>
Any idea on how to achive this?
You can replace android:scaleType="centerCrop" with android:scaleType="fitXY" to change the image default form and ration
From the documentation:
Scale the image using Matrix.ScaleToFit#FILL
<ImageView
android:id="#+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="0dp"
android:src="#drawable/image"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:gravity="center"
android:filter="true"
android:elevation="1dp"
android:scaleType="fitXY" />
I am adding the android studio preview so you can see how it looks:
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);