Is there a way to achieve a glow effect on a Layout? - android

I need to do this effect on a layout like the following :
I tried with gradient on a shape, shadows, https://developer.android.com/reference/android/graphics/drawable/NinePatchDrawable , https://developer.android.com/reference/android/graphics/BlurMaskFilter
or even some libraries: https://github.com/SanojPunchihewa/GlowButton
But it always depends on a bitmap or on a button
What I have for the moment is my drawable and layout :
Shape drawable with strokes :
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="22.5dp"/>
<padding android:left="3dp" android:right="3dp" android:top="3dp" android:bottom="3dp"/>
<stroke android:color="#color/colorAccent" android:width="1dp"/>
<solid android:color="#android:color/transparent"/>
</shape>
Layout :
<LinearLayout
android:id="#+id/text_selections"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="#drawable/btn_rounded_accent_light_stroke"
android:gravity="center"
android:layout_gravity="center"
android:orientation="horizontal"
android:tag="perso_button_rounded_accent_light">
<TextView
android:id="#+id/text_selections_line_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:tag="perso_text_view_accent"
android:text="Ma Commande"
android:layout_marginRight="5dp"
android:textColor="#color/colorAccent"
android:textSize="17sp" />
<Button
android:layout_width="25dp"
android:layout_height="25dp"
android:text="5"
android:textColor="#color/colorBlueLight"
android:background="#drawable/bg_rounded_button"
android:shadowRadius="90">
</Button>
</LinearLayout>
The library is rendering like following which is pixelating
Do you have an idea on how to do this effect ? (I want to do it programmatically, not using an image)
Thanks in advance

Related

remove small part from the circle

Hi friends please help here i trying to do below shape more than three days but cant able to get it how can i do it
But the Output i am getting is this one
Below is my code
close_drawable.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<solid android:color="#30000000"/>
<size android:height="70dp" android:width="70dp"/>
</shape>
<clip android:gravity="left" android:clipOrientation="horizontal"/>
</item>
<item android:drawable="#drawable/close" android:width="50dp" android:height="50dp" android:gravity="center"/>
</layer-list>
And my Xml Code is
<RelativeLayout
android:id="#+id/bottomroot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dp"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="#+id/nope"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/close_drawable" />
<ImageView
android:id="#+id/superlike"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-1.5dp"
android:layout_toRightOf="#+id/nope"
app:srcCompat="#drawable/superlike_drawable" />
<ImageView
android:id="#+id/like"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-1.5dp"
android:layout_toRightOf="#+id/superlike"
app:srcCompat="#drawable/like_drawable" />
<ImageView
android:id="#+id/like_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-1.5dp"
android:layout_toRightOf="#+id/like"
app:srcCompat="#drawable/likelist_drawable" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/superlike"
android:layout_alignEnd="#+id/superlike"
android:gravity="center"
android:layout_below="#+id/superlike"
android:text="Mashalla!"
android:textColor="#fff" />
</RelativeLayout>
Your circle xml shoul look like this:
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" >
<solid android:color="#20000000" />
<size
android:width="70dp"
android:height="70dp" />
</shape>
EDIT: this can happen if you have paddings in the layout that holds the ImageVIew

I would like to create a textView surrounded rounded circle the diagram as shown below

I would like to create a textView surrounded rounded circle the diagram as shown below:
Image Link :- https://i.stack.imgur.com/E0cMB.png
Can anyone of you let me know how to do this?
Check this how to implement the above image requirement.
Your Layout data should be like this:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#004473">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_margin="5dp"
android:background="#drawable/linear_layout_corner_shape"
android:orientation="horizontal">
<TextView
android:layout_width="60dp"
android:layout_height="60dp"
android:gravity="center"
android:text="01"
android:background="#drawable/textview_circle_shape"
android:textSize="20sp"
android:textColor="#000000"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="15dp"
android:text="Lorum Ipusum"
android:textSize="20sp"
android:textColor="#FFFFFF"/>
</LinearLayout>
</LinearLayout>
Drawable files data:
linear_layout_corner_shape.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#004473"></solid>
<stroke
android:width="2dp"
android:color="#FFFFFF"></stroke>
<corners android:radius="30dp"></corners>
textview_circle_shape.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#FFFFFF"></solid>

TextView and EditText android

I want to set a text view and edit text on same line in android.
As I've wrote here I should do it with linear layout like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="200px"
android:orientation="horizontal"
android:layout_alignParentLeft="true"
android:background="#android:color/background_light"
android:layout_alignParentStart="true"
android:layout_below="#+id/loginTitle"
android:layout_marginTop="5dp">
<TextView
android:layout_width="wrap_content"
android:text="Phone"
android:layout_height="200px"
android:gravity="center"
android:id="#+id/phoneTV"
android:textColor="#f7941e"
android:textSize="20sp">
</TextView>
<EditText android:layout_width="wrap_content"
android:id="#+id/phoneNumber"
android:layout_height="200px"
android:gravity="center"
android:background="#android:color/background_light"
android:text="0.00"
android:textSize="20sp"
android:inputType="number|numberDecimal"
android:layout_marginLeft="10dp">
</EditText>
</LinearLayout>
but it doesn't look at all as I want to.
My goal is to reach this component
Can you please help me how to do such a thing?
Thanks in advance!
Eden Ben simon
I put this together because I like its simple look.
Here is the final look of it.
layout
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#2c2d2d"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="5dp"
android:background="#drawable/item_holder"
android:orientation="horizontal">
<TextView
android:id="#+id/phoneTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/item"
android:gravity="center"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp"
android:text="Phone"
android:textColor="#f7941e"
android:textSize="16sp">
</TextView>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#bdbfc1"/>
<EditText
android:id="#+id/phoneNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/item_info"
android:gravity="left"
android:inputType="number|numberDecimal"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp"
android:text="516-678-7325"
android:textColor="#6d6e71"
android:textSize="16sp">
</EditText>
</LinearLayout>
</RelativeLayout>
Drawable Files Create three drawable files in the drawables folder. Used to create round corners.
item_holder.xml
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<stroke
android:width="1dp"
android:color="#b9bbbe"/>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp"/>
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:radius="0dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp"/>
</shape>
item.xml
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="0dp"
android:radius="0dp"
android:topLeftRadius="5dp"
android:topRightRadius="0dp"/>
</shape>
item_info.xml
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#f1f1f2"/>
<corners
android:bottomLeftRadius="0dp"
android:bottomRightRadius="5dp"
android:radius="0dp"
android:topLeftRadius="0dp"
android:topRightRadius="5dp"/>
</shape>
Create a background for your TextView
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- This is the line -->
<item android:right="-1dp">
<shape>
<solid android:color="#FFFFFF"/>
<stroke
android:width="1dp"
android:color="#BDBFC1"/>
<corners
android:bottomLeftRadius="7dp"
android:bottomRightRadius="0dp"
android:radius="1px"
android:topLeftRadius="7dp"
android:topRightRadius="0dp"/>
</shape>
</item>
</layer-list>
And your EditText
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- This is the line -->
<item android:left="-1dp">
<shape>
<solid android:color="#F1F1F2"/>
<stroke
android:width="1dp"
android:color="#BDBFC1"/>
<corners
android:bottomLeftRadius="0dp"
android:bottomRightRadius="7dp"
android:radius="1px"
android:topLeftRadius="0dp"
android:topRightRadius="7dp"/>
</shape>
</item>
</layer-list>
Put this into your activity
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
>
<TextView
android:id="#+id/tvPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="#drawable/text_view_background"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="Phone"
android:textColor="#F7941E"
android:textSize="20sp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#id/tvPhone"
android:layout_alignTop="#id/tvPhone"
android:layout_toRightOf="#id/tvPhone"
android:background="#drawable/edit_text_background"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textColor="#F7941E"/>
</RelativeLayout>
It looks like this, you just need to fine tune it a bit ;)
change the attribute in LinearLayout to android:orientation="vertical"
Change orientation to vertical and use layout_weight for both of your views.
Adjust the values to obtain the desired effect. More info here: Linear Layout
You can use drawable left attribute
android:drawableLeft="#drawable/name_icon_edittext"
Make separate image with text 'phone' and create an 9 patch image for Edittext background. I hope it will work !
Use dp instead px. It seems like a perfect place to just use a LinearLayout with orientation horizontal with a weights.
There is no need to write 200px every time just use Match parent.
So go with a LinearLayout with orientation: Horizontal unless I'm missing something here
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#drawable/bgmainactivity"
android:orientation="horizontal">
<TextView
android:id="#+id/phoneTV"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="0.5dp"
android:layout_weight="0.3"
android:background="#android:color/background_light"
android:gravity="center_vertical|center_horizontal"
android:padding="5dp"
android:text="Phone"
android:textColor="#f7941e"
android:textSize="20sp"
android:textStyle="bold"></TextView>
<!--U can use some like this to add divider -->
<!--<TextView-->
<!--android:layout_width="1dp"-->
<!--android:layout_height="match_parent"-->
<!--android:background="#android:color/background_dark"></TextView>-->
<EditText
android:id="#+id/phoneNumber"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="0.5dp"
android:layout_weight="0.8"
android:background="#EBEBEB"
android:gravity="center_vertical|center_horizontal"
android:inputType="number|numberDecimal"
android:padding="5dp"
android:text="0.00"
android:textSize="20sp"></EditText>
**bgmainactivity.Xml**
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#565656" />
<stroke
android:width="1dp"
android:color="#565656" />
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp" />
<corners
android:bottomLeftRadius="7dp"
android:bottomRightRadius="7dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
I just hope remaining denting panting will done by your self.
Happy Coding

Background programatic drawable cropped

I want to make a button with a letter inside a circle, without using a picture.
My button is defined like this:
<Button
android:id="#+id/zoomInButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="10dp"
android:background="#drawable/circle"
android:text="+"
android:textColor="#color/white"
android:textSize="62sp" />
<Button
android:id="#+id/zoomOutButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="10dp"
android:background="#drawable/circle"
android:text="-"
android:textColor="#color/white"
android:textSize="62sp" />
And with circle being:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<stroke
android:width="3dp"
android:color="#color/white" />
<solid android:color="#android:color/transparent" />
</shape>
However, the circle is not centred and the text is cropped:
How to center the background on the text?
Try to reduce textSize of those Buttons' because there is not enough room for 62sp thats why the texts are cropped.

how to restrict image to show insider border

my screen not show image fit on border is goes out of border seeimage http://imgur.com/VMwFMzf is show tomoattow and cheexz image out of frame help me how do i fixed it?? i want to show first two images inside border like third image bread which correctly show inside border
holder.txtText = (TextView) convertView.findViewById(R.id.title2);
holder.imgThumb = (ImageView) convertView.findViewById(R.id.image2);
holder.txtText.setText(fifthscreen.Category_name.get(position));
imageLoader.DisplayImage(fifthscreen.Category_image.get(position),
activity, holder.imgThumb);
<com.schoollunchapp.HorizontalListView
android:id="#+id/listview2"
android:layout_width="wrap_content"
android:layout_height="150dp"
android:layout_below="#+id/test_button_text5"
android:background="#ffffff"/>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:id="#+id/image2"
android:layout_width="90dp"
android:layout_height="100dp"
android:scaleType="centerCrop"
android:paddingRight="5dp"
android:paddingLeft="5dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#drawable/imagebgborder"
android:src="#drawable/icon"
/>
<TextView
android:id="#+id/title2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000"
android:padding="15dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:gravity="center_horizontal"
/>
</LinearLayout>
<!--imageborder.xml--->
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" />
<stroke android:width="1dp" android:color="#000000" />
<padding android:left="2dp" android:top="2dp" android:right="2dp"
android:bottom="2dp"
/>
<corners android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp"
android:topLeftRadius="10dp" android:topRightRadius="10dp"/>
</shape>
Use this code
<ImageView
android:id="#+id/imageview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true" />
Then follow below points:
Set your image to Imageview as 'src' and not as 'background'.
Crop your image width and height related to your Frame height and width.

Categories

Resources