I have a form with a format of:
<LinearLayout>
<RelativeLayout>TextView EditText Button</RelativeLayout>
<RelativeLayout>TextView EditText Button</RelativeLayout>
<RelativeLayout>TextView EditText Button</RelativeLayout>
<RelativeLayout>TextView EditText Button</RelativeLayout>
</LinearLayout>
I have aligned the TextView to parentLeft, the Button to parentRight. And so far, the EditText to toLeftOf Button. Now, I want the EditText to all line up with the longest TextView, however I can't seem to use toRightOf of a TextView from a different layout. I'm not even sure that's the best way to do it.
What is the proper way to get everything to line up straight?
Consider using TableLayout instead
You can try replacing the LinearLayout with RelativeLayoutand and remove the RelativeLayout for each row or use TableLayout as asahi suggested.
Related
I'm trying to add emojis in a LinearLayout but I don't know if it's possible or not. What I want to do is when I press emoji it should appear in a LinearLayout rather than EmojiEditText. Is it possible?
I have searched for quite a while but I can't find any solution to my problem. Please suggest a library or solution that supports displaying of emojis in LinearLayout.
Rather than go for library, You can do from scratch as well.
Make one Linear layout and append that linear layout as the emoji is pressed.
For that, Give ID to the linear layout and append the layout by adding view to it.
LinearLayout linearLayout;
linearLayout = findViewById(R.id.linearLayout);
linearLayoutAmi.addView("VIEW_ACCORDING_TO_EMOJI");
Emojis are in text format, and LinearLayout does not have a text property unlike a widget. Wrap each selected emoji in a TextView and then add the textview into the target LinearLayout as child view.
I need to do this in my app:
and so I need a way to put the ImageView, the TextView and the EditText.
What's the best way to do it? I thought to put all into a TextView but the size of this is too small and so it's not a good idea.
I think also to use RelativeLayout but there are also other ways to do it?
Thanks
Everything is in horizontal, so I suggest to use LinearLayout. Inside it:
TextView with drawableLeft
EditText
TextView
As you see all views are horizontal so i suggest Linear Layout
and make orientation horizontal.
and use
1.use shape
2.text view
3.textview
I have an edittext which has a width depending on another view on its top which is a textview. I set both the views to wrap content so that the edittext will copy the textview's width. But, when the edittext is completely filled up, the characters make a new line. How can I make it such that when the edittext is completely filled up the characters are only moving to the left. If possible, I do not want to hardcode the width. Is there any solution for this? Thanks.
Add this to your EditText XML:
android:singleLine="true"
android:maxLines="1"
android:singleLine="true" only
I have a simple layout in a table that consists of 3 rows. The second column may have either an EditText or a TextView like in the picture below:
Now, my question is how can I align the start of the text in EditText and TextView so that they are visually under each other (the texts, not the controls)? In the image above, the text in the second line starts too much to the left. I don't want to hardcode the padding as it may not work the same way on different devices.
try setting a padding for the second textview.
android:padding="5dp"
Instead of making the TextView match the EditText, make the EditText match the TextView by making its background null:
<EditText ... android:background="#null" ... />
The underline in the EditText then goes away and everything lines up perfectly.
I am trying to fit two EditTexts horizontally. What I am trying to accomplish is make the text keep scrolling right without the EditText extending in anyway when there is no more space in that specific EditText. This happens when the EditText is set to match_parent (width), but when I set an actually width or wrap_content, it breaks to the next line. Not the behavior I am hoping for. Any ideas?
If I understood your question correctly, you're saying you want the edit text to be a single line each? If so, have you tried using the xml attribute
android:singleLine
Or you can accomplish the same thing with:
setSingleLine() //called on the edit text
I just tested it out with 2 edit texts in a horizontal linear layout set to 100dp width each and I think it accomplishes the behavior you want.
You can try this:
Set both to fill_parent and layout_weight=1. This will align them side by side.