Not too sure how to word this but if you look at my picture below the blue of Victoria disappears off the screen but i'd like to to start a new line so you can clearly see the whole thing.
Heres my xml for for each list component. I have 5 textviews which are situated to the right of the preceding one, how can I pickup when one is too long for the line and move to another line?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/tube_stop_graphic1"
android:orientation="horizontal"
android:gravity="center_vertical|center_horizontal"
android:layout_width="25sp"
android:layout_height="25sp"
android:scaleType="fitXY"/>
<ImageView
android:id="#+id/tube_stop_graphic2"
android:orientation="horizontal"
android:gravity="center_vertical|center_horizontal"
android:layout_width="25sp"
android:layout_height="25sp"
android:scaleType="fitXY"
android:layout_below="#id/tube_stop_graphic1"/>
<ImageView
android:id="#+id/tube_stop_graphic3"
android:orientation="horizontal"
android:gravity="center_vertical|center_horizontal"
android:layout_width="25sp"
android:layout_height="25sp"
android:scaleType="fitXY"
android:layout_below="#id/tube_stop_graphic2"/>
<TextView
android:id="#+id/tube_stop_name"
android:orientation="horizontal"
android:paddingLeft="10px"
android:textSize="20sp"
android:text="BLABLA"
android:textStyle="normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/tube_stop_graphic1"/>
<TextView
android:id="#+id/tube_stop_distance"
android:orientation="horizontal"
android:layout_alignParentRight="true"
android:gravity="right|center"
android:paddingRight="10px"
android:text="BLABLA"
android:textSize="14sp"
android:textStyle="normal"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toRightOf="#id/tube_stop_name"/>
<TextView
android:id="#+id/tube_line1"
style="#style/Tube_Stop_TextView"
android:text="Overgound"
android:layout_toRightOf="#id/tube_stop_graphic1"
android:layout_below="#id/tube_stop_name"/>
<TextView
android:id="#+id/tube_line2"
style="#style/Tube_Stop_TextView"
android:layout_toRightOf="#id/tube_line1"
android:layout_below="#id/tube_stop_name"/>
<TextView
android:id="#+id/tube_line3"
style="#style/Tube_Stop_TextView"
android:layout_toRightOf="#id/tube_line2"
android:layout_below="#id/tube_stop_name"/>
<TextView
android:id="#+id/tube_line4"
style="#style/Tube_Stop_TextView"
android:layout_toRightOf="#id/tube_line3"
android:layout_below="#id/tube_stop_name"/>
<TextView
android:id="#+id/tube_line5"
style="#style/Tube_Stop_TextView"
android:layout_toRightOf="#id/tube_line4"
android:layout_below="#id/tube_stop_name"/>
</RelativeLayout>
and the style for each of them
<style name="Tube_Stop_TextView">
<item name="android:gravity">center_vertical|center_horizontal</item>
<item name="android:paddingLeft">5sp</item>
<item name="android:paddingTop">5sp</item>
<item name="android:paddingBottom">5sp</item>
<item name="android:paddingRight">5sp</item>
<item name="android:textSize">10sp</item>
<item name="android:textStyle">normal</item>
<item name="android:background">#drawable/rounded_square</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:inputType">text</item>
</style>
It will be better if you wrap all your textviews in a gridview. Because your first TextView is having long text here. Gridview will push any view which is out of available width to a new row.
Related
So I've been struggling centring this button in my View for about 3 hours I've gave up and came here to ask for some advice from more experienced android developers.
For now it looks like this.
I would like to look something like this
My view looks like this in code:
<RelativeLayout
android:id="#+id/receptionLineAddQuantityAndSeries"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:paddingBottom="#dimen/padding_layout">
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_above="#+id/layoutQntInput"
local:MvxBind="Visibility Article.SeriesType, Converter=Visibility;">
<Mvx.MvxImageView
android:id="#+id/articleSeriesImage"
android:src="#drawable/ic_list_white_48dp"
android:layout_width="wrap_content"
android:scaleType="center"
android:paddingRight="#dimen/padding_layout"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_alignParentRight="true"
android:background="#drawable/button_border"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp" />
<RelativeLayout
android:id="#+id/layoutInputSeries"
android:paddingLeft="#dimen/padding_layout"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="58dp">
<TextView
android:id="#+id/suppliersSearchInputLabelCode"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_alignParentTop="true"
style="#style/ExtendProTheme.EditTextLabel"
local:MvxBind="Visibility Article.SeriesType, Converter=Visibility; Text Article.SeriesType, Converter=ArticleSeriesTypeToLabel;" />
<CC.CustomEditText
android:id="#+id/inventoryIdentifyArticleEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:theme="#style/ExtendProTheme"
android:maxLength="20"
android:layout_below="#+id/suppliersSearchInputLabelCode"
style="#style/ExtendProTheme.EditText"
local:MvxBind="Text Article.SeriesName, Mode=TwoWay; Error Errors['SeriesName']; Visibility Article.SeriesType, Converter=Visibility; Hint Article.SeriesType, Converter=ArticleSeriesTypeToHint; EnterCommand GetSeriesTotalQuantityCommand; FocusChangeCommand GetSeriesTotalQuantityCommand;" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
What i've tried so far is all the combination of
android:scaleType = fitXY, fitCenter, center, matrix
fixed widths for the ImageView, no results...
Any help would be nice.
I've tried all the answers below and they still didn't show as expected. I found a version that looks close to what i need .
<Mvx.MvxImageView
android:layout_width="48dp"
android:layout_height="match_parent"
android:src="#drawable/ic_list_white_48dp"
android:id="#+id/articleSeriesImage"
style="#style/ExtendProTheme.ListButtonSeriesStyle">
<style name="ExtendProTheme.ListButtonSeriesStyle">
<item name="android:scaleType">matrix</item>
<item name="android:paddingRight">#dimen/padding_layout</item>
<item name="android:layout_marginLeft">8dp</item>
<item name="android:layout_marginRight">8dp</item>
<item name="android:layout_marginTop">8dp</item>
<item name="android:background">#drawable/button_border</item>
<item name="android:layout_alignParentRight">true</item>
<item name="android:layout_gravity">center</item>
</style>
try this one :)
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="#+id/receptionLineAddQuantityAndSeries">
<Mvx.MvxImageView
android:id="#+id/articleSeriesImage"
android:src="#drawable/ic_list_white_48dp"
android:layout_width="60dp"
android:layout_height="match_parent"
android:scaleType="center"
android:paddingRight="#dimen/padding_layout"
android:gravity="center"
android:layout_alignParentRight="true"
android:background="#drawable/button_border"
android:layout_marginRight="15dp"
android:layout_centerVertical="true"/>
<TextView
android:id="#+id/suppliersSearchInputLabelCode"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
style="#style/ExtendProTheme.EditTextLabel"
local:MvxBind="Visibility Article.SeriesType, Converter=Visibility; Text Article.SeriesType, Converter=ArticleSeriesTypeToLabel;" />
<CC.CustomEditText
android:id="#+id/inventoryIdentifyArticleEditText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:theme="#style/ExtendProTheme"
android:maxLength="20"
android:layout_below="#+id/suppliersSearchInputLabelCode"
android:layout_toLeftOf="#+id/articleSeriesImage"
style="#style/ExtendProTheme.EditText"
local:MvxBind="Text Article.SeriesName, Mode=TwoWay; Error Errors['SeriesName']; Visibility Article.SeriesType, Converter=Visibility; Hint Article.SeriesType, Converter=ArticleSeriesTypeToHint; EnterCommand GetSeriesTotalQuantityCommand; FocusChangeCommand GetSeriesTotalQuantityCommand;" />
</RelativeLayout>
try this ,check for syntax
<RelativeLayout>
<TextView
id=#+id/yourtxtv
/>
<ImageView
android:layout_alignBaseline
android:align_right_to="#+id/yourtxtv"
android:margin_right=xxxx(put the value u want to put)
/>
</RelativeLayout>
This is what I tried and found:
<RelativeLayout
android:id="#+id/receptionLineAddQuantityAndSeries"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
<ImageView
android:id="#+id/articleSeriesImage"
android:src="#drawable/ic_android"
android:background="#color/blue"
android:layout_width="wrap_content"
android:scaleType="center"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_alignParentRight="true"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp" />
<RelativeLayout
android:id="#+id/layoutInputSeries"
android:paddingLeft="64dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="58dp">
<TextView
android:id="#+id/suppliersSearchInputLabelCode"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="sn"
android:layout_alignParentTop="true"/>
<EditText
android:id="#+id/inventoryIdentifyArticleEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:theme="#style/ExtendProTheme"
android:maxLength="20"
android:layout_below="#+id/suppliersSearchInputLabelCode"/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
The solution was
<Mvx.MvxImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:src="#drawable/ic_list_white_48dp"
android:id="#+id/articleSeriesImage"
style="#style/ExtendProTheme.ListButtonSeriesStyle">
<style name="ExtendProTheme.ListButtonSeriesStyle">
<item name="android:scaleType">matrix</item>
<item name="android:paddingRight">#dimen/padding_layout</item>
<item name="android:layout_marginLeft">8dp</item>
<item name="android:layout_marginRight">8dp</item>
<item name="android:layout_marginTop">8dp</item>
<item name="android:background">#drawable/button_border</item>
<item name="android:layout_alignParentRight">true</item>
<item name="android:layout_gravity">center</item>
</style>
It's the only way it worked . Thanks all for ideas.
I have created a custom toolbar which has a spinner. I am trying to set a custom colour for the spinner arrow - currently the default is white, but it's not working, any ideas?
This is my Toolbar layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/newToolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
android:elevation="0dp"
android:windowContentOverlay="#null"
android:orientation="horizontal">
<ImageView
android:id="#+id/strLogo"
android:layout_width="45dp"
android:layout_height="40dp"
android:layout_marginTop="13dp"
android:scaleType="fitCenter"
android:visibility="gone"
android:background="#ffffff"
android:src="#mipmap/logo"/>
<TextView
android:id="#+id/updateName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:layout_toRightOf="#+id/strLogo"
android:layout_centerVertical="true"
android:text="Test"
android:visibility="visible"
android:textColor="#ffffff"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="normal" />
<Spinner
android:id="#+id/spinner_nav"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
style="#style/customSpinnerTheme"
android:visibility="visible"/>
</RelativeLayout>
This my style xml for the spinner:
<style name="customSpinnerTheme" parent="ThemeOverlay.AppCompat">
<item name="colorControlActivated">#FFFFFF</item>
<item name="colorControlHighlight">#FFFFFF</item>
</style>
You can add this type of style in your spinner style and add your colors which you want to use as your drawable:
<style name="SpinnerAppTheme" parent="android:Widget.Spinner">
<item name="android:background">#drawable/apptheme_spinner_background_holo_light</item>
<item name="android:dropDownSelector">#drawable/apptheme_list_selector_holo_light</item>
</style>
i want to create header in android with text and buttons like in iOS (Text in Cetner and Buttons on right and left side), i have tried but not useful at all,please guide me ... how can i make this one for my app
Try this. Make header.xml file and put below code in it and use it in any layout file using include .
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#drawable/titlebar"
android:gravity="center">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/back_button"
android:background="#android:color/transparent"
android:layout_marginLeft="5.0dip"
android:id="#+id/imageButtonBack"
android:contentDescription="#string/ui_image_home_description"/>
<TextView
android:id="#+id/textViewTitleBar"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
style="#style/TitleBarText"
android:singleLine="false"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/home_button"
android:background="#android:color/transparent"
android:layout_marginRight="5.0dip"
android:id="#+id/imageButtonHome"
android:contentDescription="#string/ui_image_home_description"/>
</LinearLayout>
Note : Add the below style to style.xml in res/values folder.
<style name="TitleBarText">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_weight">1</item>
<item name="android:gravity">center_vertical</item>
<item name="android:textSize"> 17sp </item>
<item name="android:paddingLeft">12dip</item>
<item name="android:paddingRight">12dip</item>
<item name="android:textColor">#color/white</item>
<item name="android:singleLine">true</item>
<item name="android:ellipsize">end</item>
</style>
This is an easier one. You can try this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#drawable/header">
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Back" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Next" />
</RelativeLayout>
</RelativeLayout>
I'm trying to manage my application style using a custom theme:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.Styled" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="actionBarTabStyle">#style/Widget.Sherlock.Light.ActionBar.TabView</item>
<item name="android:actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="android:textViewStyle">#style/MyTextViewStyle</item>
</style>
<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="background">#drawable/background</item>
<item name="android:background">#drawable/background</item>
</style>
<style name="MyTextViewStyle" parent="#android:style/Widget.TextView">
<item name="android:textColor">#color/text</item>
</style>
</resources>
As you can see, I set the TextView default color to #color/text (#ff000000). This works OK in all the TextViews of my application except the ones in my custom list item layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/mov_concept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="2dp"
android:textSize="16dp"
android:textStyle="bold" />
<TextView
android:id="#+id/mov_category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/mov_concept"
android:layout_marginLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/mov_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/mov_category"
android:layout_centerHorizontal="true"
android:layout_marginBottom="6dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/mov_period"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/mov_amount"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/mov_until"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/mov_period"
android:layout_alignBottom="#+id/mov_period"
android:layout_alignParentRight="true"
android:layout_marginBottom="2dp"
android:layout_marginRight="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/mov_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/mov_concept"
android:layout_alignBottom="#+id/mov_category"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:layout_marginTop="2dp" />
</RelativeLayout>
I don't know why this happens, thank you in advance.
I had the same problem because of using Application Context instead of Activity Context for ListAdapter. To fix the issue I changed my code from
MyAdapter adapter = new MyAdapter(getApplicationContext(), ...)
to
MyAdapter adapter = new MyAdapter(MyActivity.this, ...)
It's because you apply a android:textAppearance to your textviews which override the color of your style.
Below is the XML I am using and when I use the android:textStyle="italic" attribute, the text doesn't show up. Basically any TextView with the style SummarySubtitle will not show up.
<style name="SummarySubtitle" parent="#android:style/TextAppearance">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:gravity">right|center_vertical</item>
<item name="android:layout_weight">1</item>
<item name="android:paddingRight">6dp</item>
<item name="android:textSize">12dp</item>
<item name="android:textStyle">italic</item>
</style>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="70dp"
android:orientation="vertical">
<LinearLayout android:id="#+id/summary_header"
android:layout_width="fill_parent" android:layout_height="30dp"
android:orientation="horizontal">
<TextView android:id="#+id/summary_title" android:text="Title"
style="#style/SummaryTitle"/>
<TextView android:id="#+id/summary_subtitle"
android:text="Subtitle " style="#style/SummarySubtitle"/>
</LinearLayout>
<LinearLayout android:id="#+id/summary_subheader"
android:layout_width="fill_parent" android:layout_height="20dp"
android:orientation="horizontal">
<TextView android:id="#+id/summary_min" android:text="#string/min"
style="#style/SummaryHeader"/>
<TextView android:id="#+id/summary_max" android:text="#string/max"
style="#style/SummaryHeader"/>
<TextView android:id="#+id/summary_avg" android:text="#string/avg"
style="#style/SummaryHeader"/>
</LinearLayout>
<LinearLayout android:id="#+id/summary_values"
android:layout_width="fill_parent" android:layout_height="20dp"
android:orientation="horizontal">
<TextView android:id="#+id/summary_value_min"
android:text="$0.00" style="#style/SummaryValue"/>
<TextView android:id="#+id/summary_value_max"
android:text="$0.00" style="#style/SummaryValue"/>
<TextView android:id="#+id/summary_value_avg"
android:text="$0.00" style="#style/SummaryValue"/>
</LinearLayout>
</LinearLayout>
All I found on the subject so far
http://groups.google.com/group/android-developers/browse_thread/thread/843376e298e95e14
Relevant quote: "Oh yeah, I have seen that too. But when you run your app, it renders
correctly."
It doesn't show up on the layout's graphical representation but works correctly when you build and run the app.
try using this code:
adInfoTV.setTypeface(Typeface.MONOSPACE,Typeface.ITALIC);