In a relativelayout I am using the code below. If the total width is too high tvProgress should be cut off. The problem is that I don't know how to determine which view should be cut off. The current code lets list_lib_episodes_watched_total cut off. How can I determine that tvProgress is cut off instead?
...
<TextView
android:id="#+id/tvProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/list_lib_et_episodes_watched"
android:layout_toRightOf="#+id/list_lib_cover"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:lines="1"
android:singleLine="true"
android:text="Progress:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/list_lib_et_episodes_watched"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/list_lib_status_spinner"
android:layout_toRightOf="#+id/tvProgress"
android:hint="0"
android:imeOptions="actionSend"
android:inputType="number"
android:maxEms="4"
android:maxLength="4"
android:text="0" />
<TextView
android:id="#+id/list_lib_episodes_watched_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/list_lib_et_episodes_watched"
android:layout_toLeftOf="#+id/list_lib_episodes_watched_increase"
android:layout_toRightOf="#+id/list_lib_et_episodes_watched"
android:lines="1"
android:singleLine="true"
android:text="/0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#707070" />
<ImageButton
android:id="#+id/list_lib_episodes_watched_increase"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/list_lib_et_episodes_watched"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/list_lib_et_episodes_watched"
android:layout_marginLeft="6dp"
android:layout_marginRight="8dp"
android:adjustViewBounds="true"
android:background="#drawable/btn_transparant"
android:contentDescription="Increase by 1"
android:minWidth="60dp"
android:scaleType="centerInside"
android:src="#drawable/ic_increase" />
...
Why cut any view?? It is wrap_content so you cannot determine like that. Put everything inside . Then nothing will be cut. You can scroll and see everything.
ScrollView is like this:
<ScrollView
android:id="#+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:fillViewport="true">
---
---
---
</ScrollView>
Related
Here is my layout:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="65dp"
android:layout_marginStart="20dp"
android:gravity="center_vertical|start"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="18.9dp"
android:lineSpacingExtra="64sp"
android:textColor="#484848"
android:textSize="16sp"
tools:text="அனைத்து அனைத்துஅனைத்து" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:lineSpacingExtra="64sp"
android:text="0"
android:textAlignment="center"
android:textColor="#color/red_500"
android:textSize="14sp" />
</LinearLayout>
All other languages are working fine, except tamil language is very big.
I need an icon at beginning and sometimes it show number of notifications at end. So I need to set ellipsize to text on middle.
How to achieve this?
you can use android:ellipsize atrribute to do that.
like this :
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="18.9dp"
android:lineSpacingExtra="64sp"
android:textColor="#484848"
android:textSize="16sp"
android:ellipsize="end"
android:maxLines="1"
tools:text="அனைத்து அனைத்துஅனைத்து" />
note: don't forget to use android:maxLines attribute to set the line number of your text.
I'm trying to make an image fit into the EditText itself using drawableLeft, without any padding or "whitespaces" around it.
This is what the image looks like for now
This is how it should look like
I tried increasing the size of the image itself but it made the EditText expand even more.
Here's the XML file:
<EditText
android:layout_marginTop="6dp"
android:id="#+id/login_password"
android:layout_width="315dp"
android:layout_height="wrap_content"
android:textSize="17dp"
android:textColor="#8d8e8f"
android:hint="Password"
android:drawableLeft="#drawable/sample"
android:singleLine="true"
android:inputType="textPassword"
android:layout_below="#+id/login_name"
android:layout_centerHorizontal="true" />
How can the image fit inside the EditText? Does it something to do about the image itself?
You can try the LinearLayout for it. Means in the LinearLayout , you should put the Editext's drawable image as the background , and than divide it in to three parts,1st part is for the password_image , 2nd one for your EditText and and 3rd last one for is your INVISIBLE View, which prevent , your EditText value to touch at end
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/EDITEXT_DRAWABLE"
android:gravity="center_vertical"
android:padding="5dp"
android:weightSum="2">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:gravity="left|center"
android:src="#drawable/sample" />
<EditText
android:id="#+id/password_et"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1.5"
android:background="#android:color/transparent"
android:ems="10"
android:gravity="center"
android:hint="********"
android:inputType="textPassword"
android:paddingLeft="-10dp"
android:singleLine="true"
android:imeOptions="actionDone"
android:textColor="#android:color/white"
android:textColorHint="#android:color/white" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|left"
android:layout_weight="0.1"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:src="#drawable/sample"
android:visibility="invisible" /> ///PUT THE VIEW INVIIBLE
</LinearLayout>
Just use a Fram layout it works well use a frame layout and inside it edit text and an image view is created set the background of image view to transperent and gravity to the right or to the left
<FrameLayout
android:layout_width="match_parent"
android:layout_height="25dp">
<EditText
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_gravity="left|center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/border_round"
android:drawableLeft="#color/place_autocomplete_search_text"
android:drawableStart="#drawable/places_ic_search"
android:drawableRight="#drawable/arrowxml">
</EditText>
<ImageView
android:layout_width="25dp"
android:background="#android:color/transparent"
android:scaleType="centerCrop"
android:layout_gravity="right"
android:src="#drawable/searcharrow"
android:layout_height="25dp" />
use this...........
<EditText
android:id="#+id/user_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/editback"
android:drawableLeft="#drawable/useremail"
android:drawablePadding="10dp"
android:hint="#string/user_name"
android:padding="7dp"
android:singleLine="true"
android:textColor="#9291A1"
android:textSize="15sp" />
This is a simple question but its kicking my butt all around xml land.
All I want to do is to have the two edit text fields separated by a colon and to have the colon be centered like the following:
00:30
Right now when it displays the colon is slightly lower than the 00 and 30 of the edit text fields
I have tried using android:layout_marginBottom= "10dp" but that doesn't work. Any ideas? Thanks
Here is my code:
<EditText
android:id="#+id/edit_minute"
android:layout_width="wrap_content"
android:layout_height="85dp"
android:layout_below="#+id/text_minute"
android:layout_marginLeft="45sp"
android:inputType="number"
android:text="#string/edit_minute"
android:textColor="#0D4F8B"
android:textSize="70sp"
android:textStyle="bold" />
<TextView
android:id="#+id/text_colon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/edit_minute"
android:layout_below="#+id/text_minute"
android:textAlignment="center"
android:text="#string/text_colon"
android:textSize="70sp"
android:textStyle="bold" />
<EditText
android:id="#+id/edit_second"
android:layout_width="105dp"
android:layout_height="85dp"
android:layout_below="#+id/text_minute"
android:layout_toRightOf="#+id/text_colon"
android:inputType="number"
android:text="#string/edit_second"
android:textColor="#0D4F8B"
android:textSize="70sp"
android:textStyle="bold" />
Put Layout_height of Both edittext to wrapcontent without giving a specific height then the three views would be aligned.....
<EditText
android:id="#+id/edit_minute"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/text_minute"
android:layout_marginLeft="45sp"
android:inputType="number"
android:text="08"
android:textColor="#0D4F8B"
android:textSize="70sp"
android:textStyle="bold" />
<TextView
android:id="#+id/text_colon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/edit_minute"
android:layout_below="#+id/text_minute"
android:textAlignment="center"
android:text=":"
android:textSize="70sp"
android:textStyle="bold" />
<EditText
android:id="#+id/edit_second"
android:layout_width="105dp"
android:layout_height="wrap_content"
android:layout_below="#+id/text_minute"
android:layout_toRightOf="#+id/text_colon"
android:inputType="number"
android:text="30"
android:textColor="#0D4F8B"
android:textSize="70sp"
android:textStyle="bold" />
I would first put them all in a RelativeLayout, and place this layout under "text_minute".
Then in the following I centered all, and the colon's height is adjusted using the attributes layout_alignTop and layout_alignBottom that force the TextView to follow the first EditText height:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/text_minute" >
<EditText
android:id="#+id/edit_minute"
android:layout_width="wrap_content"
android:layout_height="85dp"
android:layout_toLeftOf="#+id/text_colon"
android:inputType="number"
android:text="#string/edit_minute"
android:textColor="#0D4F8B"
android:textSize="70sp"
android:textStyle="bold" />
<TextView
android:id="#+id/text_colon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:layout_alignTop="#+id/edit_minute"
android:layout_alignBottom="#+id/edit_minute"
android:gravity="center_horizontal"
android:text="#string/text_colon"
android:textSize="70sp"
android:textStyle="bold" />
<EditText
android:id="#+id/edit_second"
android:layout_width="wrap_content"
android:layout_height="85dp"
android:layout_toRightOf="#+id/text_colon"
android:inputType="number"
android:text="#string/edit_second"
android:textColor="#0D4F8B"
android:textSize="70sp"
android:textStyle="bold" />
</RelativeLayout>
You can place your EditText TextView and EditText all in a LinearLayout and use android:baselineAligned and android:baselineAlignedChildIndex.
If you require your parent view is a RelativeLayout then you can use android:layout_alignBaseline on each of the child views.
I'm trying to create a widget with several different lines on it and want to set it to auto scroll (marquee) and have the ability to adjust the scrolling speed. How can I accomplish this?
I tried using a TextView and was able to make it scroll on one line, but that's it. I can't seem to adjust the speed of it or have two lines scrolling at the same time.
An example of this is: https://play.google.com/store/apps/details?id=huntsman.stocktickertapelite&hl=en
OR
https://play.google.com/store/apps/details?id=com.cousinHub.widget
Anyone have an idea of how they did it? (custom views?)
Thanks.
This is what I have so far:
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:textStyle="bold"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/app_name"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit ="marquee_forever"
android:scrollHorizontally="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:duplicateParentState="true"
android:layout_weight="1">
<requestFocus
android:focusable="true"
android:focusableInTouchMode="true"
android:duplicateParentState="true" />
</TextView>
Try this, I am getting the text from Java as setText file, and show in this screen
<ScrollView
android:id="#+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/line_dotted"
android:layout_marginBottom="10dp"
android:fillViewport="true"
android:scrollbars="vertical" >
<TextView
android:id="#+id/text_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="15sp"
android:layout_marginRight="15sp"
android:layout_marginTop="10sp"
android:scrollbars="vertical"
android:textColor="#0A2A1B"
android:textSize="12sp" />
</ScrollView>
Or You can try this without scrollview, the text will scroll when there is more than 5 ines
<EditText
android:id="#+id/Comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/Submitbtn"
android:layout_alignParentLeft="true"
android:layout_below="#+id/ratingBar"
android:layout_marginBottom="40dp"
android:ems="10"
android:gravity="left"
android:hint="Comments"
android:maxLines="5"
android:padding="20dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
android:imeOptions="actionDone" />
How can I achieve the following layout, with TextView being a TextView with ellipsize end and View being wrap_content and immediately to the right of TextView ?
Here are three examples of how the layout should behave, with different TextView width :
|[TextView] [View] |
|[TextView TextView] [View] |
|[TextView TextView T...] [View]|
[Edit]
The following TableLayout gives the correct behaviour :
<TableLayout
android:id="#+id/upper_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/alert_button"
android:shrinkColumns="0"
android:stretchColumns="2" >
<TableRow>
<TextView
android:id="#+id/name_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:includeFontPadding="false"
android:lines="1"
android:paddingTop="2dp"
android:scrollHorizontally="true" />
<TextView
android:id="#+id/unread_count_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:gravity="center"
android:includeFontPadding="false"
android:paddingBottom="0dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="2dp" />
</TableRow>
</TableLayout>
The TableLayout uses 3 columns, the last being the hack : the strechColumns property makes it take all available space, so the second TextView is always immediatly to the right of the first one.
The first TextView ellipsize correctly because of the shrinkColumns property.
However, I don't like the idea of using a TableLayout to achieve that.
Does anybody know a better way ?
Thanks
Try this (I cannot check it now, but to my point of view it should work):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="6dip" >
<TextView
android:id="#+id/my_txtvw_txtvw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:ellipsize="marquee"
android:maxLines="1" />
<TextView
android:id="#+id/my_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/my_txtvw_txtvw"
android:maxLines="1" />
</RelativeLayout>
Try this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/my_view"
android:ellipsize="end"
android:maxLines="1"
android:layout_alignParentLeft="true"
android:text="blablabla blablabla"
android:layout_centerVertical="true"
android:gravity="center_vertical|left" />
<TextView
android:id="#+id/my_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:maxLines="1" />
</RelativeLayout>
I'm not sure if you want android:ellipsize="end" or android:ellipsize="marquee". I think the layout will work fine to you, just replace the ellipsize value id needed.
Let me know about your progress...