How to remove Android Slider Bottom Effect? - android

Currently, I am using smarteist/android-image-slider for my app project.
The problem I am facing is, that I want to remove the default gray shading effect and make it transparent.
I have added one sample image, I want my slider to be like with no bottom shading.
Means: with no bottom effect.
How do I do that?
Is there any other libraries that I can use to get a more exact look like the sample image slider?
<com.smarteist.autoimageslider.SliderLayout
android:id="#+id/imageSlider"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_alignParentTop="true"
android:focusableInTouchMode="true" />
Have a look at the slider here
https://i.stack.imgur.com/t4San.png

Related

How to create angled ribbon with textview

I'm trying to create such a list of items in android, I am able to complete almost everything except the orange ribbon on the right top corner, I tried different methods to achieve this UI element but none of them works properly for me. I tried rotating a text view by 45ยบ with the ribbon image as background but the edges of the ribbon weren't perfect I also tried adding the ribbon as an image view and placed a text view on top of that but It was really difficult to place the ribbon and text view like this. So what is the easiest and most efficient way to achieve this?
Thanks in advance.
I don't think there is a native android component that supports such a feature. You can create a custom view making use of the path. Here is a great tutorial if you want to follow it.
Put this TextView into your FrameLayout/CardView:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ff8f00"
android:textSize="16sp"
android:text="25% Off"
android:layout_gravity="end"
android:paddingStart="30dp"
android:paddingEnd="30dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="-20dp"
android:rotation="45"
/>
To achieve best look, play with padding and margin attributes.

How to show slider value above the slider also when we are not sliding using material.slider in Android?

This is how I want to show the value of the slider. Please find the picture
This is currently not supported, the available options in LabelFormatter (which can be applied to sliders with slider.setLabelFormatter(...) are:
LabelFormatter.LABEL_FLOATING: Label visible during interaction only
LabelFormatter.LABEL_WITHIN_BOUNDS: Label visible during interaction only
LabelFormatter.LABEL_GONE: Label never visible
You can find the code here with the extensive javadoc explanation.
You could open a feature request for this on the Material GitHub issues page
You can set the label behaviour "visible" in the XML file. So in the slider XML code, you just need to add
app:labelBehavior="visible"
Below I am attaching a sample XML code for the same.
<com.google.android.material.slider.Slider
android:id="#+id/seek_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:valueFrom="1"
android:valueTo="100"
android:layout_gravity="center"
android:layout_margin="15dp"
app:tickColor="#0000FF"
app:labelStyle="#style/Tooltip"
app:labelBehavior="visible"
/>

Is it possible to disapper the border of image button at particlualr selected areas in android?

I am trying to set a border for few of the image buttons for a particular screen layout in android. But for some buttons, I want to disable the border if the screen-layout background is blue colour. Please help me how to do this?
(I assume you design your app with Material Theme)
I think you can't do it (maybe possible with some hacky technique), because it's not intended to be that way.
Google has designed each view to underline each of their own purposes. So, I believe, If you can modify a button that way, it won't felt like a button to users thus can raise some misunderstanding.
What possibly user think if such button that doesn't have default blue, exist? Do they still think that as a Button?
Personally, I suggest that you leave the border as-is, if you still intended to make it feels like a Button.
Otherwise, if you really need it, you can always use CardView, put an ImageView inside it and attach OnClickListener to it. I think the result is quite similar because almost every rectangular view Google has nowadays, got similar visual to CardView.
Btw, I made this in my recent project to achieve a borderless Button-ey Image. Maybe it'll help.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
card_view:cardElevation="4dp"
card_view:cardUseCompatPadding="true"
card_view:contentPadding="0dp">
<ImageView
android:id="#+id/clickable_photo_thumbnail_image_view"
android:layout_width="#dimen/photo_thumbnail_size"
android:layout_height="#dimen/photo_thumbnail_size"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
</android.support.v7.widget.CardView>
(UPDATE) This is the screenshot from my app, produced with above code:
(In my screenshot, I already use a RecyclerView)

Android use vector drawable to replace text in button

Currently I have a button that looks like this:
What I want to do is to be able to replace the text with this vector drawable but keep the blue rectangle background:
I looked into doing this but I cannot seem to get it right.
I tried the following combination:
<Button
android:id="#+id/deletebutton"
android:layout_width="0dp"
android:layout_height="50dp"
android:src="#drawable/deletebtn24dp"
android:backgroundTint="#color/primaryButtonColor"
android:layout_weight="1"/>
However that just led to a blank blue button with no drawable. What can I do so the drawable replaces the text?
Also I would like to support API levels start at 16+.
You have to use app:srcCompat="#drawable/deletebtn24dp" instead of android:src="#drawable/deletebtn24dp". Using an ImageButton might also be better than using a straight Button.

android.support.design.widget.FloatingActionButton implenetation of FAB reduces image size

So I have started migrating to the official support design library for an Android app of mine, replacing elements as I go. I just replaced an FAB (implemented as ImageButton) with official android.support.design.widget.FloatingActionButton. But the icon inside the button is smaller as compared to the one it was in ImageButton. What may have been a reason?
FloatingActionButton's implementation:
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon" />
Tried adding app:fabSize="normal but that didn't work, either.
This is how it looks after using FloatingActionButton:
And this is how it looked like while using it as a ImageButton:
Set scale type to android:scaleType="center"
Just a guess since you haven't provided any details at all. The design library's FloatingActionButton has padding calculations which will shrink the icon if it is too large, whereas your ImageButton probably just centers the icon with no scaling at all. I'm guessing that you would not observe this behavior if you were using a correctly sized 24dp icon, like the ones you get from: https://www.google.com/design/icons/.
You can use : app:maxImageSize="..dp" to change the size of your icon!

Categories

Resources