The text view tv_title is always displayed above the activity even though when I've set bottom margin 0dp.
Here is the screenshot:
Also when bottom margin is 10 dp, the text view goes further up:
I hope I understood the problem, since the question isn't clear (I don't understand what's the outcome you want) and you didn't add your whole xml code.
tv_title and tv_desc have 120dp space between them because tv_desc has marginTop 120dp. When you add marginBottom = 10dp to tv_title, the space equals to 130dp.
In RelativeLayout, if you want to display tv_title beneath tv_desc, add layout_below field to tv_title.
And it would be better for you to see some RelativeLayout examples.
May be you are using noactionbar theme so it does't appear . but if you want using without actionbar than just use :
android:layout_marginTop="?attr/actionBarSize"
this may help.
or Use :
remove android:layout_above="#+id/tv_desc" from tv_title textview. and add android:layout_below="#+id/tv_title" in tv_desc textview will help you.
Related
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
I would like to achieve something like this:
I need that these two texviews would not have space between them. I specify no margin to them, but android already has a little bit margin by default and makes a little bit space. I would like to shrink that space :)
you can give negative margin to view.
Set same background for both TextView
You can specify Minus Margin like android:marginLeft=-5dp for Right side TextView or android:marginRight=-5dp for Left side TextView.
Thanks.
Try to create a second TextView inside the First one like
In XML, create a Second TextView like:
android:layout_alignBottom="#+id/firstTxtView"
android:layout_alignRight="#+id/firstTxtView"
android:layout_alignTop="#+id/firstTxtView"
try to set TextView's background #0000(transparent).
try to set margin left=-5dp or something to second TextView
I have done some basic xml layout from the Internet and I am confused as to what android:gravity would be used for vs android:layout-gravity. The UI designer seems to respond well when I change the layout_gravity, but I get no response to the regular gravity? What is up with this?
Is this similar to layout parameters with fill-parent and match-parent? one is gone now.
android:gravity is a statement from a parent to its content, indicating where the content should slide within the available parent space (if there is room for such sliding).
android:layout_gravity is a request from a child to its parent, asking that it be slid in a certain direction (if there is room for such sliding).
layout_gravity - It contains and it belongs to component's parent layout. Like if you set one TextView in LinearLayout, LinearLayout's width is fill_parent, but TextView basically will set at left-top. So now if you would give layout_gravity=right then your TextView will be shifted to top-right corner. But the text will not change its place. i.e. you had been wrote "Hello world" then "hello world" will not be changed to right, but its parent textView will be changed to right. So here in this case it will belongs to LinearLayout, means parent Layout.
gravity- It contains and it belongs to TextView as per above explanation. if you will give gravity="right" then "Hello-world" text will go to right-top corner of TextView not LinearLayout.
I'm adding a TextView to a parent LinearLayout RelativeLayout programmtically. There is enough space for the text to be displayed horizontally but for some reason the text is displayed vertically. Does anyone know what's going on here?
It's really hard to say what is the problem without looking at your XML and layout code. In my experience, sometimes it happens when the parent layout has height set as WRAP_CONTENT and the views inside it have wrong weight config, for example one has weight but WRAP_CONTENT and the other MATCH_PARENT (Sorry, I don't remember the case exactly). I suggest you check your LayoutParams carefully or set a fixed width and height for the TextView to see what is the problem.
You can also post your code here so we can have a look at it