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.
Related
I want to create title,body of text, other icons such as picture and link. How can I display the title and body of text as shown in the following picture? Which layout is better ? Constraint, Linear or Grid? How do we choose these layouts?
Constraint layout is best layout & much more flexible.
For title & body, you can use CardView at background and place your views like TextView/Edittext, ImageView/ImageButton on it. You may need to place another Constraint Layout in cardView for its inner view
I've been making all of my views dynamically, and now I've come to the point where I want to add an EditText for people to write in.
I've been able to accomplish this for the most part, but it doesn't look right. I have a linear layout that I'm adding a relative layout to. I'm making the relative layout have a white background, then adding the EditText. Problem is, it always adds it to the direct center of the relative layout, and options to align it vertically to the top have so far failed.
I also need to be able to pull the text from it later when a separate button was pressed (I know how to make the button work, it's the pulling text from it part I'm a bit iffy on). Here's my code so far:
public void addEditText(LinearLayout L){
EditText myEditText = new EditText(c);
myEditText.setSingleLine(false);
RelativeLayout l1 = new RelativeLayout(c);
LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(scWidth1, 300);
lp.gravity=Gravity.CENTER;
l1.setLayoutParams(lp);
l1.setBackgroundColor(Color.WHITE);
l1.setGravity(Gravity.CENTER_VERTICAL);
l1.addView(myEditText);
L.addView(l1);
}
l1.setGravity(Gravity.CENTER_VERTICAL); places the EditText in center vertical of the parent container i.e RelativeLayout, remove that line.
I've seen many of questions for how to add TextView in a RelativeLayout programatically, but everybody adding it in LinearLayout with orientation vertical. Can any one suggest me or give me a link that how to add multiple TextView in RelativeLayout at right until it has space and then change the line.
I want a layout like this..
May be this works for you !
You can customize chips-edittext-library for your need. Customizing by setting background to transparent, and editable to false.
-> Or you can use any other library which is used for displaying emoticon in EditText and customize it according to your need. Like android-emoticon-edittext-spike
You can use the Flow Layout library that manages the view arrangement itself.
When there is no space left the added View is moved to the next line
how can i mange Textview in layout.? please help me..
how can i set textview and border then again textview.
Just create a horizontal LinearLayout, and add an ImageView, a TextView, a View with width 2dp and height match_parent, and a TextView as children.
Either repeat that for every row, or use the recommended approach of using a ListView with the above mentioned layout as rows.
I'd use two compound TextViews: Just create a horizontal LinearLayout, and add a TextView with drawableLeft="#drawable/icon_location" and another one with drawableLeft="#drawable/line_vertical" as children.
For both, a drawablePadding="8dp" or whatever you like best
Is it possible to create a Button, whose background drawable is a layout?
For example, I would like to create a layout with some horizontal images and some textviews, and all the resulting view should be clickable all at once as a single button.
Would it be possible, and how?
Thank you.
LinearLayout yourLayout = (LinearLayout) findViewById(R.id.your_nested_layout);
yourLayout.setOnclickListener(...);