I would like to rotate a TextView 90 degrees. This works, however, the TextView gets "cut" in the y-axis (namely to the screen width, see screenshot).
How could I fix this?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<TextView
android:rotation="90"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="256"
android:textSize="50mm"
android:gravity="center"
android:id="#+id/TextView" />
</LinearLayout>
EDIT:
I am sure that the TextView gets cut, not my Layout.
Try changing the android:layout_height in the Textview to "wrap_content".
Besides doing as CodeZero said, add this to the LinearLayout:
android:clipChildren="false"
android:clipToPadding="false"
Related
i have an imageview on a relative layout.
You can see in the screenshot :
How can i move the imageview(the weel) in the bottom-right corner, but display only 25 % part of it, like in the follow picture:
Thanks in advance !
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:background="#E0E0E0"
>
<com.androidsources.welcomescreen.MyRecyclerView
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:id="#+id/cardList"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<com.anupcowkur.wheelmenu.WheelMenu
android:id="#+id/wheelMenu"
android:layout_width="300dp"
android:layout_height="300dp"
android:src="#drawable/wheel"/>
</RelativeLayout>
You can try something like this:
<com.anupcowkur.wheelmenu.WheelMenu
android:id="#+id/wheelMenu"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:paddingLeft="150dp"
android:paddingTop="150dp"
android:src="#drawable/wheel"/>
alignParentRight and alignParentBottom attributes will move your widget at the right bottom corner. Also try to change padding to achieve desired visual effect.
I know that there is already an answer, but for those who can't make the accepted answer work here is an alternative.
For some reason, I can't place part of the view outside the parent if I'm using RelativeLayout but when I tried LinearLayout it worked. So the solution I used is to enclose the view in a LinearLayout then position the LinearLayout on bottom-end of the parent.
<LinearLayout
android:layout_width="300dp"
android:layout_height="300dp"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true">
<ImageView
android:layout_width="300dp"
android:layout_height="300dp"
android:src="#drawable/some_pic"
android:layout_marginStart="150dp"
android:layout_marginTop="150dp"/>
</LinearLayout>
Note the width and height of the image is not match_parent, using match_parent will shrink the image not displace it.
Even when gravity is set to top the text has some padding between it and view's border. I need to text to completely touch the border.
Bellow you can see the gap I'm trying to get rid of.
And here is the layout used:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/someView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Here is some text"
android:textSize="30dp"
android:gravity="top" />
</LinearLayout>
Try to create 9.patch line and set it to your TextView: android:drawableTop="#drawable/your_line".
Then set android:drawablePadding="-10dp"
This trick must work perfectly.
Try this on TextView in your xml file :
android:includeFontPadding="false"
--
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/someView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Here is some text"
android:textSize="30dp"
android:includeFontPadding="false"
android:gravity="top" />
</LinearLayout>
In xml try,
android:paddingTop="-5dp"
Negative paddings always seem to work for me.
Set the height manually instead of wrapping the content.
The linear layout is the item with the padding. You need to modify that element as well to remove the space.
I'm trying to make a ImageView inside a HorizontalScrollView, but the imageView gets twice the width of the screen and end halfway out of bounds.
My XML:
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/horizontalScrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:baselineAligned="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/penguins" />
</LinearLayout>
</HorizontalScrollView>
And a image of what I get (click me!)
Does anyone know a solution to this problem?
Greetings
I copied your xml and using my resource it looks perfect, i believe your resource is bigger than you think it is, you probably should use layout_width and layout_height as fix size and also set scaleType to centerInside.
I'm trying to create an expandable list where I can make the height of the group_row smaller, to use less screen space. When I change the layout_height of the LinearLayout, it changes the height to what I want it, but all of the labels of each TextView aren't displayed; they disappear. However, when it is wrap_content, the text appears. Any ideas how to fix?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="35dp">
<TextView android:id="#+id/childname
android:paddingLeft="0dp"
android:textSize="16dp"
android:textStyle="italic"
android:layout_width="150dp"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
Textview id should be android:id="#+id/childname"
I'm trying to position an image below a TextView in a RelativeLayout but it doesn't work. when i set its position using android:layout_below. This is my xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="#ccc"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/app_details_1"
android:text="#string/app_details_1"
android:textColor="#347"
android:gravity="center"
android:textSize="9pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<ImageView
android:id="#+id/logo"
android:src="#drawable/secs"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="#+id/appdetails_1" <!-- I'm setting it here -->
/>
</RelativeLayout>
Instead it just places the image at the top left of the screen. How do I position it? Is layout_below a wrong positioning code?
There's a mistake in your xml. Must be
android:layout_below="#id/app_details_1"
it should be ok, but first try to make sure the textView is positioned on top by using layout_alignParentTop="true" for the textView and see if it does the trick.