I have a simple table layout that looks like this:
http://imgur.com/beU9LbR
My problem is that whenever I type text into the Artist, Venue or Comments EditText boxes, once the text string is in line vertically with the start of the Date TextView, the TextView start position moves position to stay in line with the string of characters; like this:
http://imgur.com/7f7eal8
I'm not sure if the Button is trying to match its end point to the string of characters or if the TextView is trying to match its start point to the string of characters but either way somethings not right.
Can anyone give me some insight as to what is happening here?
Thanks in advance!
Here is the XML file for the page shown:
<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"
tools:context="${relativePackage}.${activityClass}" >
<TextView
style="#style/titleBar"
android:id="#+id/addTitle"
android:text="#string/add" />
<TableLayout
style="#style/my_table"
android:id="#+id/addTable"
android:layout_below="#+id/addTitle">
<TableRow>
<TextView
style="#style/largeText"
android:text="#string/artistName"/>
</TableRow>
<TableRow>
<EditText
style="#style/tableEditText"
android:id="#+id/editName"/>
</TableRow>
<TableRow>
<TextView
style="#style/largeText"
android:text="#string/venue"/>
</TableRow>
<TableRow>
<EditText
style="#style/tableEditText"
android:id="#+id/editVenue"/>
</TableRow>
<TableRow>
<TextView
style="#style/largeText"
android:text="#string/date"/>
</TableRow>
<TableRow>
<Button
android:background="#android:color/transparent"
android:drawableRight="#drawable/event_1"
android:id="#+id/setDateButton"/>
<TextView
style="#style/tableEditText"
android:layout_weight="3"
android:layout_width="200dp"
android:id="#+id/editDate"/>
</TableRow>
<TableRow>
<TextView
style="#style/largeText"
android:text="#string/comments"/>
</TableRow>
<TableRow>
<EditText
style="#style/tableEditText"
android:inputType="textNoSuggestions|textCapSentences|textMultiLine"
android:lines="3"
android:id="#+id/editComments"/>
</TableRow>
</TableLayout>
<Button
android:id="#+id/addButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="#drawable/add"
android:background="#android:color/transparent"
android:textColor="#color/grey"
android:padding="20dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
Here is the styles.xml file:
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="largeText">
<item name="android:textColor">#color/grey</item>
<item name="android:textSize">25sp</item>
<item name="android:padding">3dp</item>
<item name="android:layout_weight">1</item>
<item name="android:gravity">left</item>
<item name="android:layout_marginRight">20sp</item>
</style>
<style name="largeText2">
<item name="android:textSize">25sp</item>
<item name="android:padding">3dp</item>
<item name="android:background">#color/bgOrange</item>
<item name="android:textColor">#color/nearBlack</item>
<item name="android:layout_weight">1</item>
<item name="android:gravity">left</item>
<item name="android:layout_marginRight">20sp</item>
</style>
<style name="titleBar">
<item name="android:textColor">#fff</item>
<item name="android:textSize">25sp</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_alignParentTop">true</item>
<item name="android:layout_centerHorizontal">true</item>
<item name="android:gravity">left</item>
<item name="android:padding">20sp</item>
<item name="android:background">#color/headingOrange</item>
</style>
<style name="my_table">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:padding">15sp</item>
</style>
<style name="tableEditText">
<item name="android:inputType">textCapSentences|textNoSuggestions|textAutoComplete</item>
<item name="android:background">#color/bgOrange</item>
<item name="android:textColor">#color/nearBlack</item>
<item name="android:gravity">left</item>
<item name="android:padding">3dip</item>
<item name="android:textSize">25sp</item>
<item name="android:layout_weight">1</item>
</style>
<style name="smallIcon">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_gravity">left</item>
<item name="android:padding">2dp</item>
</style>
</resources>
This is happening because of your use of the TableLayout while not fully appreciating how it works. What it does is it goes through and figures out how many columns it will have. For each TableRow it will put the views in each column starting from the first defined view to the last.
What is happening is that your first TextView for artistName is in column 1. The next few TableRow only have 1 column. Then you get to the TableRow with setDateButton which creates two columns. Now all the other views previously assigned will be in column 1 with a column 2 after them which would be as wide as editDate if they had another view.
As a result setDateButton is now as wide as your artistName TextView and since you are using android:drawableRight the image is being placed to the right side of the Button.
You're going to need to adjust layout_column and layout_span values to adjust the layout. Alternatively, I would suggest removing the TableLayout and using the RelativeLayout appropriately.
Try wrapping the Button and TextView with a LinearLayout
Related
I have a TextView and this is the xml code for it
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:orientation="horizontal"
android:padding="10dp" >
<TextView
android:id="#+id/sidelist_item_count"
style="#style/HomeTextViewItemCount"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"/>
</RelativeLayout>
And this is my Style
<style name="HomeTextViewItemCount">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:background">#drawable/home_textview_count</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">10sp</item>
<item name="android:gravity">center</item>
<item name="android:layout_marginRight">5dp</item>
<item name="android:layout_marginBottom">5dp</item>
<item name="android:textColor">#android:color/white</item>
</style>
I want to make my TextView circular. This doesn't expand when there are 3 digit numbers entered. But if I remove the style attribute from the TextView and set android:background="#drawable/home_textview_count" in my text view and added rest of the attributes inside Style into my Text view. then it works as expected. Can I know why cannot we set the style and what's the mistake I have done?
Please help me.
Thank you!
I have created a simple table with varies length of text. I'm using layout_height=wrap_content in my table row. If you see the picture, it has a wide spaces between the next element and the previous one. If I set the height, then the spaces will remained when viewed in landscape. I don't know where to fixed it. I mostly used styles... so it's weird that some are working and some not.
sampleLayout.xml
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="90dp"
android:background="#color/form_background"
android:shrinkColumns="*"
android:stretchColumns="*">
<!--Table header-->
<TableRow
style="#style/table_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/th_component"
style="#style/table_header"
android:layout_height="match_parent"
android:layout_weight="2.8"
android:text="#string/tableH_komponen"/>
<TextView
android:id="#+id/th_marks"
style="#style/table_header"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/tableH_markah"/>
<TextView
android:id="#+id/th_demerits"
style="#style/table_header"
android:layout_height="match_parent"
android:layout_weight="0.7"
android:text="#string/tableH_demerit"/>
<TextView
android:id="#+id/th_notes"
style="#style/table_header"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:text="#string/tableH_catatan"/>
</TableRow>
<!--Component C1-->
<TableRow
style="#style/table_row"
android:layout_height="wrap_content">
<TextView
style="#style/table_attr"
android:text="#string/c1"/>
<TextView
android:id="#+id/tv_cC1"
style="#style/table_component"
android:text="#string/cC1"
/>
<TextView
android:id="#+id/tv_mc1"
style="#style/table_marks"
android:layout_height="wrap_content"
android:text="#string/_6"/>
<CheckBox
android:id="#+id/checkBox_c1"
style="#style/table_demerit"
android:layout_height="wrap_content"/>
<ImageButton
android:id="#+id/btn_c1"
style="#style/table_notes"
android:layout_height="wrap_content"
android:text="#string/catatan"/>
</TableRow>
<!--Component C2-->
<TableRow
style="#style/table_row"
android:layout_height="wrap_content">
<TextView
style="#style/table_attr"
android:text="#string/c2"/>
<TextView
android:id="#+id/tv_cC2"
style="#style/table_headComponent"
android:text="#string/cC2"/>
<ImageButton
android:id="#+id/btn_c2"
style="#style/table_notes"
android:layout_height="wrap_content"
android:text="#string/catatan"/>
</TableRow>
<TableRow
style="#style/table_row"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tv_cC2_1"
style="#style/table_subComponent"
android:text="#string/cC2_1"/>
<TextView
android:id="#+id/tv_mC2_1"
style="#style/table_marks"
android:layout_height="match_parent"
android:text="#string/_1"/>
<CheckBox
android:id="#+id/checkBox_c2_1"
style="#style/table_subDemerit"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow
style="#style/table_row"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tv_cC2_2"
style="#style/table_subComponent"
android:layout_height="wrap_content"
android:text="#string/cC2_2"/>
<TextView
android:id="#+id/tv_mC2_2"
style="#style/table_marks"
android:layout_height="wrap_content"
android:text="#string/_1"/>
<CheckBox
android:id="#+id/checkBox_c2_2"
style="#style/table_subDemerit"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
</FrameLayout>
strings.xml
<resources>
<!--Case C-->
<string name="cC1">Pemeriksaan kesihatan ke atas semua pengendali makanan:
\n - Mendapat suntikan pelalian anti-tifoid
\n - Menghadiri Latihan Pengendali Makanan </string>
<string name="cC2">Tahap kebersihan diri yang baik:</string>
<string name="cC2_1">- Berpakaian bersih dan bersesuaian</string>
<string name="cC2_2">- Memakai apron yang bersih dan berpenutup kepala</string>
</resources>
styles.xml
<resources>
<!--kpkt table header-->
<style name="table_header">
<item name="android:textSize">#dimen/textSize_subheading</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#color/table_textcolor</item>
<item name="android:background">#color/table_background</item>
<item name="android:padding">#dimen/text_padding</item>
<item name="android:layout_width">0dp</item>
<item name="android:gravity">center</item>
</style>
<!--table style-->
<style name="table_row">
<item name="android:gravity">end</item>
<item name="android:layout_width">0dp</item>
<item name="android:weightSum">5</item>
</style>
<style name="table_attr">
<item name="android:layout_width">0dp</item>
<item name="android:layout_weight">0.3</item>
<item name="android:gravity">center</item>
</style>
<style name="table_component">
<item name="android:layout_width">0dp</item>
<item name="android:layout_weight">2.5</item>
<item name="android:paddingTop">8dp</item>
<item name="android:paddingBottom">8dp</item>
</style>
<style name="table_marks">
<item name="android:layout_width">0dp</item>
<item name="android:layout_weight">1</item>
<item name="android:gravity">center</item>
<item name="android:padding">8dp</item>
</style>
<style name="table_demerit">
<item name="android:layout_width">0dp</item>
<item name="android:layout_weight">0.7</item>
<item name="android:gravity">center_horizontal</item>
<item name="android:visibility">visible</item>
</style>
<style name="table_notes">
<item name="android:layout_width">0dp</item>
<item name="android:layout_weight">0.5</item>
<item name="srcCompat">#drawable/ic_edit</item>
<item name="android:contentDescription">catatan</item>
<!--<item name="android:drawableBottom">#drawable/ic_edit</item>-->
<!--<item name="android:drawableTop">#drawable/ic_edit</item>-->
</style>
<!--kpkt table head component-->
<style name="table_headComponent">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">40dp</item>
<item name="android:padding">#dimen/text_padding</item>
<item name="android:layout_weight">4.2</item>
</style>
<!--kpkt table subcomponent-->
<style name="table_subDemerit">
<item name="android:layout_width">0dp</item>
<item name="android:layout_weight">1.2</item>
<item name="android:visibility">visible</item>
</style>
<style name="table_subComponent">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">40dp</item>
<item name="android:padding">8dp</item>
<item name="android:layout_weight">2.5</item>
</style>
</resources>
I can suggest you to understand the concept of wrap_content and match_parent, to get better solution.
I think you can use linear layout with horizontal and vertical orientation.
Because linear layout is more flexible and gives you better performance than table layout and table row.
Q: When we should use table layout and table row?
Ans: when we have a similar type of data, and we want to represent in rows and columns view then we should use table layout and table row.
But if we have non linear data, then we should not use table layout and table row...and I think you have non linear data.
For better understanding of showing data in non linear form, you should know the weight_sum and layout_weight property of linear layouts.
I was wondering how I can manage to align all columns in rows. I am using a ListView, where I display a list of drugs for my game. The columns are different sizes each row. I would like to see that each column has the same width all down to the end of the list, but not have same width overall.
As you can see from the picture, the columns are not aligned. I draw the lines to make it even more obvious what I would like. You can also see that the buttons are to close to the other column. With the arrow on the picture I wanted to make it clear that those buttons should be placed more to the end of the row.
My implementation uses the following styles:
<!-- List style for the drug sell list -->
<style name="traderY.List">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_alignParentLeft">true</item>
<item name="android:layout_alignParentTop">true</item>
</style>
<!-- Header style for quantity column -->
<style name="traderY.HeaderQuantityText">
<item name="android:layout_width">0dip</item>
<item name="android:layout_weight">0.15</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">15dip</item>
<item name="android:padding">4dip</item>
<item name="android:layout_margin">4dip</item>
<item name="android:textColor">#EDEFF0</item>
</style>
<!-- Header style for cost column -->
<style name="traderY.HeaderCostText">
<item name="android:layout_width">0dip</item>
<item name="android:layout_weight">0.20</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">15dip</item>
<item name="android:padding">4dip</item>
<item name="android:layout_margin">4dip</item>
<item name="android:textColor">#EDEFF0</item>
</style>
<!-- Header style for name column -->
<style name="traderY.HeaderNameText">
<item name="android:layout_width">0dip</item>
<item name="android:layout_weight">0.45</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">15dip</item>
<item name="android:padding">4dip</item>
<item name="android:layout_margin">4dip</item>
<item name="android:textColor">#EDEFF0</item>
</style>
<!-- Row style for quantity column -->
<style name="traderY.QuantityListText">
<item name="android:layout_width">0dip</item>
<item name="android:layout_weight">0.15</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">15dip</item>
<item name="android:padding">4dip</item>
<item name="android:layout_margin">4dip</item>
<item name="android:textColor">#000000</item>
</style>
<!-- Row style for cost column -->
<style name="traderY.CostListText">
<item name="android:layout_width">0dip</item>
<item name="android:layout_weight">0.20</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">15dip</item>
<item name="android:padding">4dip</item>
<item name="android:layout_margin">4dip</item>
<item name="android:textColor">#000000</item>
</style>
<!-- Row style for name column -->
<style name="traderY.NameListText">
<item name="android:layout_width">0dip</item>
<item name="android:layout_weight">0.45</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">15dip</item>
<item name="android:padding">4dip</item>
<item name="android:layout_margin">4dip</item>
<item name="android:textColor">#000000</item>
</style>
<!-- Row style for button column -->
<style name="traderY.ListButton" parent="#android:style/Widget.Button">
<item name="android:layout_width">0dip</item>
<item name="android:layout_weight">0.20</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">15dip</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#FFFFFF</item>
<item name="android:gravity">center</item>
<item name="android:shadowColor">#000000</item>
<item name="android:shadowDx">1</item>
<item name="android:shadowDy">1</item>
<item name="android:shadowRadius">0.6</item>
<item name="android:background">#drawable/custom_btn_black_pearl</item>
<item name="android:padding">4dip</item>
</style>
As you can see I set or I try to set the column width by using those two items:
<item name="android:layout_width">0dip</item>
<item name="android:layout_weight">0.20</item>
I was reading that you can set the width by using weight. I basically used the same values I would use to set percentages. If I understand correctly, the weight value represents the ratio between other components. I found this as a solution on a Stack Overflow question and I found it in several tutorials. One of the tutorials I found is this one here.
To share more light, here are also the layouts of the of all the components, starting with the fragment which contains the list view.
Fragment layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal">
<TextView
android:id="#+id/money"
style="#style/traderY.TextCenter" />
<TextView
android:id="#+id/location"
style="#style/traderY.TextCenter" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/junkie_icon"/>
<ListView
android:id="#+id/drug_list"
style="#style/traderY.List"
android:layout_weight="1"/>
<TableRow
style="#style/traderY.ButtonRow">
<Button
android:id="#+id/nothing"
style="#style/traderY.ButtonCenter"
android:text="#string/exit"/>
</TableRow>
</LinearLayout>
Here is the header layout. As you can see I omit the last column for buttons, because there is no need to display a header for it:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#000000">
<TextView
android:text="#string/header_quantity"
style="#style/traderY.HeaderQuantityText" />
<TextView
android:text="#string/header_cost"
style="#style/traderY.HeaderCostText" />
<TextView
android:text="#string/header_name"
style="#style/traderY.HeaderNameText" />
</LinearLayout>
And here is the layout for each row I use:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/drug_quantity"
style="#style/traderY.QuantityListText" />
<TextView
android:id="#+id/drug_cost"
style="#style/traderY.CostListText" />
<TextView
android:id="#+id/drug_name"
style="#style/traderY.NameListText" />
<Button
android:id="#+id/drug_sell_btn"
android:text="#string/sell_drugs_action"
style="#style/traderY.ListButton"/>
</LinearLayout>
Those are the style/layouts I use and I do not change any of those properties in the code. So the problem can only be in my XML files.
Does anyone know what am I doing wrong here? Maybe my investigation is wrong and I can not do it. I would appreciate any help or comments to solve this problem. If this is not even possible, then please let me know.
I found out that my solution was correct. The weight property did the job. For some unknown reason gradle did not see the changes when it was building the app. Or maybe it is the emulator. This was not the first time something like this happened. I will have to investigate why this even occur.
Increase weight of style="#style/traderY.QuantityListText". Make 0.2 or 0.3
Wrap your text views in a LinearLayout and set it to fill the parentView. In this way all the buttons will be aligned to the right.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/drug_quantity"
style="#style/traderY.QuantityListText" />
<TextView
android:id="#+id/drug_cost"
style="#style/traderY.CostListText" />
<TextView
android:id="#+id/drug_name"
style="#style/traderY.NameListText" />
</LinearLayout>
<Button
android:id="#+id/drug_sell_btn"
android:text="#string/sell_drugs_action"
style="#style/traderY.ListButton"/>
</LinearLayout>
I want the Marquee effect on EVERY textview in my app...so I thought I put it in a style:
<style name="MyTextViewStyle" parent="#android:style/Widget.TextView">
<item name="android:focusable">true</item>
<item name="android:focusableInTouchMode">true</item>
<item name="android:fontFamily">sans-serif-thin</item>
<item name="android:textSize">25sp</item>
<item name="android:ellipsize">marquee</item>
<item name="android:singleLine">true</item>
<item name="android:maxLines">1</item>
</style>
and set it in the app theme:
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:textViewStyle">#style/MyTextViewStyle</item>
</style>
this doe not work :(
Tried it directly on the TextView:
<TextView
android:ellipsize="marquee"
android:singleLine="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:maxLines="1"
android:id="#+id/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-5dp"
android:fontFamily="sans-serif"
android:textAllCaps="true" />
This does work...
With the following condition: the style may NOT have the 'focusable' and 'focusableInTouchMode' options.
But without these uptions in the TextView example above, it will not scroll...
so I need these attributes, but am unable to get them to work via styles...anyone have an answer?
If focusable and focusableInTouchMode not working in Style then remove from Style.xml and add in every TextView
<style name="MyTextViewStyle" parent="#android:style/Widget.TextView">
<item name="android:fontFamily">sans-serif-thin</item>
<item name="android:textSize">25sp</item>
<item name="android:ellipsize">marquee</item>
<item name="android:singleLine">true</item>
<item name="android:maxLines">1</item>
</style>
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:textViewStyle">#style/MyTextViewStyle</item>
</style>
In Your layout.xml file.
<TextView
android:focusable="true"
android:focusableInTouchMode="true"
android:id="#+id/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-5dp"
android:textAllCaps="true" />
Note : this will work if there is only one TextView in layout..
If you have many TextView as marquee in single layout then look at this example, Android-MarqueeView.
I'm guessing that android:ellipsize is not a text style element, so it is not inherited with android:textViewStyle.
Just add your MyTextViewStyle as a style to a TextView to check my guess. If this is the problem, you have to add the android:ellipsize attribute individually or in a style.
try this :
<TextView
android:focusable="true"
android:focusableInTouchMode="true"
android:id="#+id/text_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-5dp"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:textAllCaps="true" />
and marquee effect will work only if text length is bigger than scree width.
I have a spinner, an edittext and a button in a horizontal linearlayout. When I have enter something into edittext, it increase every character and others decrease. There is an eanough blank area input but it does not change, every time it increase how long character I input.
How can I fix it?
layout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/ly"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="10" >
<Spinner
android:id="#+id/spinner1"
style="#style/submitspinner"
android:layout_weight="2"
android:entries="#array/a_code"
android:prompt="#string/p_code" />
<EditText
android:id="#+id/editText1"
style="#style/submitstyle"
android:layout_weight="5"
android:inputType="number" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
style="#style/submitstyle"
android:layout_weight="3"
android:text="#string/btn_submit" />
</LinearLayout>
style
<style name="submitstyle">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_margin">10sp</item>
<item name="android:textColor">#android:color/holo_blue_dark</item>
<item name="android:textSize">#dimen/pt</item>
</style>
<style name="submitspinner" parent="#android:TextAppearance.Widget.TextView.SpinnerItem">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_margin">10sp</item>
<item name="android:textColor">#android:color/holo_blue_dark</item>
<item name="android:textSize">#dimen/pt</item>
</style>
I have changed style as below and it worked well...
submitstyle and submitspinner style
from
<item name="android:layout_width">wrap_content</item>
to
<item name="android:layout_width">0dp</item>
I found good tuts for this but I have closed the tab, I cannot share it...
//change you style from
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">match_parent</item>
//to
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>