Android EditText with icon and vertical line [duplicate] - android

This question already has answers here:
Android EditText draw a divider line between its drawable and its text
(4 answers)
Closed 6 years ago.
I need an EditText exactly like this:
EditText with icon and vertical line
Is it possible doing this at Android XML file?

Maybe this code helps you
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edit_text_selector">
<EditText
android:id="#+id/input"
android:layout_marginLeft="-10dp"
android:layout_toRightOf="#+id/your_icon"
android:text=""
android:padding="10dp"
android:background=""
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<!-- icon -->
<ImageView
android:padding="3dp"
android:id="#+id/icon"
android:src="#drawable/perm_group_personal_info"
android:layout_width="40dp"
android:layout_height="40dp" />
</RelativeLayout>

Yes.
Use FrameLayout / RelativeLayout.
either way you can position imageButton with the image as src and costume drawable that will have only 1 side line.

Related

How to set ImageView in edittext [duplicate]

This question already has answers here:
Inserting imageview inside edittext android
(4 answers)
How can I add an image on EditText
(10 answers)
Closed 4 years ago.
I am using the EditText with drawableLeft property and set ImageView in Left side for displaying mobile icon. My Question is how to put Imageview in EditText?
Please help me.
Actually i want like this.
I have tried using linear layout with horizontal. below is xml code.
<LinearLayout
android:weightSum="2"
android:layout_below="#id/welcome"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_weight="1"
android:layout_gravity="center"
android:id="#+id/image_mobile"
android:layout_width="#dimen/_50sdp"
android:layout_height="#dimen/_50sdp"
android:src="#mipmap/ic_launcher" />
<EditText
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_30sdp"
android:layout_toRightOf="#+id/image_mobile"
android:hint="Mobile number"
android:inputType="text" />
</LinearLayout>
But am not able to adjust the image view and edittext.
You should use android:drawableStart
The drawable to be drawn to the start of the text.
DEMO
<EditText
......
android:drawableStart="#drawable/your_icon"
android:drawablePadding="5dp"
/>

how we can design imageView in corner of textView in android? [duplicate]

This question already has answers here:
How to layout text to flow around an image
(9 answers)
Closed 6 years ago.
I am new in android so I am confuse in this design so please help me.
I want to design this type
Have you tried FlowTextView
How to use
Add to your XML layout with your child views inside it:
<uk.co.deanwild.flowtextview.FlowTextView
android:id="#+id/ftv"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:padding="10dip"
android:src="#drawable/android"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="400dip"
android:padding="10dip"
android:src="#drawable/android2"/>
</uk.co.deanwild.flowtextview.FlowTextView>
Then in your code:
FlowTextView flowTextView = (FlowTextView) findViewById(R.id.ftv);
Spanned html = Html.fromHtml("<html>Your html goes here....");
flowTextView.setText(html);
Add the dependency:
compile 'uk.co.deanwild:flowtextview:2.0.2'
Output:
Enjoy...

Android textview wrap custom view [duplicate]

This question already has an answer here:
How to align TextView around an ImageView?
(1 answer)
Closed 6 years ago.
I have TextView and custom view called StarRating.
There is code snippet:
<RelativeLayout
android:id="#+id/flowtextView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.app.views.StarRating
android:id="#+id/star_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/_2sdp"
android:text="by Legacy Reviewer, April 11, 2014 from Chicago IL"
android:textSize="12sp"
android:layout_alignParentTop="true"
android:layout_toEndOf="#+id/star_rating" />
</RelativeLayout>
Actual Result:
Expected Result:
The problem is that TextView is not wrapping the StarRating...
How can I do that ?
This is not HTML. In standard TextView text is layouted within TextView boundaries (rectangle), so this is working as expected. You cannot make it work differently as these views won't work that way and if they overlap they do not know about this anyway.
Another way to do it is add extra spaces in the beginning of your text. it's a little tricky though.
let me know if you want more details.
Try using android:gravity="center".
<RelativeLayout
android:id="#+id/flowtextView"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</RelativeLayout>

Create image type TextView in Android [duplicate]

This question already has answers here:
creating a strikethrough text?
(14 answers)
Closed 7 years ago.
I am new to Android. I Want to create an TextView like My Image.I search a lot, but I don't get Any Idea.
In My TextView how to draw a line on Text. Please help me.
Any Help will be Appreciated.
you can directly create this line in layout file like this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/viewline">
<TextView
android:id="#+id/txts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello to all"
android:textColor="#000000"
android:layout_centerHorizontal="true"
android:textSize="25sp" />
<View
android:layout_width="150dp"
android:layout_height="1dp"
android:layout_marginTop="15dp"
android:layout_centerHorizontal="true"
android:background="#000000"></View>
</RelativeLayout>
which gives a view like:
try this :
tv.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
For set Strikethrough.
textView.setPaintFlags(txtView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
textView.setText("10.00 AM");
For clear Strikethrough
textView.setPaintFlags(0);

android reduce space between two vertical TextViews [duplicate]

This question already has answers here:
Remove space between stacked TextViews
(9 answers)
Closed 8 years ago.
I have two vertical TextView elements in my app.
There is lot of space between TextViews, pading and layoutMargin are 0
Is there way to reduce this space?
EDIT
Here is my code:
.
.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="right"
android:paddingRight="10dp"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/text_size_extra_small"
android:textColor="#color/home_tab_text_normal"
android:text="Test1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/orange_text_color"
android:textSize="#dimen/text_size_large"
android:textStyle="bold"
android:text="Text2"/>
</LinearLayout>
.
.
Thnaks
android:includeFontPadding="false"
Negative Margins can be set by two methods -
1) by xml - set the "android:Layout_marginTop" field negative - which other people have already suggested above
2) by java (Programmatically) - set the "topMargin" field of LayoutParams to negative.
You can also refer to this
You can try by giving negative margin to any of the layout.
Like for the second tv you can give:-
android:layout_marginTop="-10dp"
or
for the first tv:-
android:layout_marginBottom="-10dp"
You might need to change the values as per your requirement

Categories

Resources