I made a RadioButton with images.
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/radioType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/background_light"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/radioAlc"
style="#style/navbar_button"
android:checked="true"
android:drawableTop="#drawable/policeradio"
android:text="Barrage" />
<RadioButton
android:id="#+id/radioCrash"
style="#style/navbar_button"
android:drawableTop="#drawable/carcrashradio"
android:layout_marginLeft="-10dp"
android:text="Accidente" />
<RadioButton
android:id="#+id/radioMarch"
style="#style/navbar_button"
android:drawableTop="#drawable/marchradio"
android:layout_marginLeft="-10dp"
android:text="Manifestation" />
<RadioButton
android:id="#+id/radioRadar"
style="#style/navbar_button"
android:drawableTop="#drawable/radarradio"
android:text="Radar" />
</RadioGroup>
the problem is that with
<item name="android:button">#null</item>
I can remove the radio button, to let the user click the image, but it seems that it keeps the space to show it. In my case, I would like to remove that extra space that is bothering me !
Is it possible???
I apply that style
<style name="navbar_button">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:button">#null</item>
<item name="android:gravity">center_horizontal</item>
<item name="android:layout_weight">1</item>
<item name="android:textSize">12dp</item>
</style>
I don't know if you use other styles we can't see here, but if I copy your code in a layout file and add this to my styles.xml:
<style name="navbar_button">
<item name="android:button">#null</item>
</style>
it works fine and there is no extra space.
EDIT:
You have to add the item <item name="android:padding">0dp</item> to your navbar_button style, then it works on Android 2.3, too.
Related
I'm trying to replicate this:
in my android app. I would like the three textviews to have a percentage based width (33%) across the screen. The triangle is a separate drawable I've created.
The issue is, I can create the percentage width in a LinearLayout, but I can't have nicely overlapping view in a LinearLayout- the Basic Info textview should be behind the triangle.
Below is the code I've got working without the triangle:
Styles:
<style name="status_selected_textview">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">#dimen/standard_line_height</item>
<item name="android:layout_weight">0.33</item>
<item name="android:gravity">center</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">#dimen/font_size_medium</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:padding">5dp</item>
<item name="android:background">#color/green</item>
</style>
<style name="status_unselected_textview">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">#dimen/standard_line_height</item>
<item name="android:layout_weight">0.33</item>
<item name="android:gravity">center</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">#dimen/font_size_medium</item>
<item name="android:textColor">#color/gray</item>
<item name="android:padding">5dp</item>
<item name="android:background">#color/light_header</item>
</style>
Layout:
<LinearLayout
android:id="#+id/activate_key_status_header"
android:layout_below="#+id/activate_key_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backround="#color/light_header">
<TextView
android:id="#+id/activate_key_textview"
android:text="Activate Key"
style="#style/status_selected_textview"/>
<TextView
style="#style/status_unselected_textview"
android:text="Basic Info" />
<TextView
android:text="Edit Profile"
style="#style/status_unselected_textview"/>
</LinearLayout>
Here is the code for my triangle that I'm trying to add somehow:
<View
android:layout_toRightOf="#+id/activate_key_textview"
android:layout_width="#dimen/standard_line_height"
android:layout_height="#dimen/standard_line_height"
android:background="#drawable/arrow_right" />
It seems like the solution is somehow a combo of a RelativeLayout and LinearLayout, but I can't seem to find the right way.
Any thoughts?
Can you wrap the 2nd TextView in a FrameLayout, and add the triangle view to it 2nd? That plus an android:gravity left would do it, I would think.
Something like this:
<FrameLayout
<!-- Whatever styles you need to make it fit 33%-->
>
<TextView
style="#style/status_unselected_textview"
android:text="Basic Info" />
<View
android:gravity="left"
android:layout_width="#dimen/standard_line_height"
android:layout_height="#dimen/standard_line_height"
android:background="#drawable/arrow_right" />
</FrameLayout>
I have a form like this :
Image
With the code :
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="570dp"
android:layout_marginTop="160dp" >
<RadioButton
android:id="#+id/button_service"
style="#style/type_action"
android:text="#string/service" />
<RadioButton
android:id="#+id/button_reception"
style="#style/type_action"
android:layout_alignLeft="#id/button_service"
android:layout_alignTop="#id/button_service"
android:layout_marginTop="10dp"
android:text="#string/defense" />
<RadioButton
android:id="#+id/button_passe"
style="#style/type_action"
android:layout_alignLeft="#id/button_service"
android:layout_alignTop="#id/button_reception"
android:layout_marginTop="10dp"
android:text="#string/passe" />
<RadioButton
android:id="#+id/button_attaque"
style="#style/type_action"
android:layout_alignLeft="#id/button_service"
android:layout_alignTop="#id/button_passe"
android:layout_marginTop="10dp"
android:text="#string/attaque" />
<RadioButton
android:id="#+id/button_bloc"
style="#style/type_action"
android:layout_alignLeft="#id/button_service"
android:layout_alignTop="#id/button_attaque"
android:layout_marginTop="10dp"
android:text="#string/bloc" />
<RadioButton
android:id="#+id/button_faute"
style="#style/type_action"
android:layout_alignLeft="#id/button_service"
android:layout_alignTop="#id/button_bloc"
android:layout_marginTop="10dp"
android:text="#string/faute" />
</RadioGroup>
And style.xml
<style name="type_action">
<item name="android:textSize">30sp</item>
<item name="android:textColor">#EEEEEE</item>
<item name="android:background">#000000</item>
<item name="android:textStyle">bold</item>
<item name="android:layout_width">200dp</item>
<item name="android:layout_height">50dp</item>
<item name="android:gravity">center</item>
</style>
I want to remove the default icons that are on my buttons.
And I wish instead of that, when a button is checked, it's is highlighted in becoming yellow for example.
How can I do that ?
Thanks for the help (and sorry for my bad english).
And I wish instead of that, when a button is checked, it's is
highlighted in becoming yellow for example.
You can define your own radiobutton_selector.xml for radio button:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="#drawable/unchecked" />
<item android:state_checked="false" android:drawable="#drawable/checked" />
</selector>
and then set it to RadioButton like
<RadioButton
android:id="#+id/button_faute"
android:button="#drawable/radiobutton_selector"
style="#style/type_action"
android:layout_alignLeft="#id/button_service"
android:layout_alignTop="#id/button_bloc"
android:layout_marginTop="10dp"
android:text="#string/faute" />
//EDIT
also i found this tutorial or tutorial1 with full source code for customizing radio buttons in way you as you want to :P
I've been trying to fix this issue for hours now but it looks like I'm the only one having it.
I shouldn't see the number above and below the blue line. Here is the XML
<android.support.v7.widget.GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:useDefaultMargins="true"
android:layout_margin="3dp"
app:columnCount="3"
app:rowCount="7">
........
<NumberPicker
app:layout_column="1"
app:layout_row="3"
android:id="#+id/n_of_dies"
style="#style/inputNumbers"
android:layout_width="wrap_content"
app:layout_gravity="fill_horizontal"
/>
<NumberPicker
app:layout_column="1"
app:layout_row="4"
app:layout_gravity="fill_horizontal"
android:id="#+id/carbon_content"
style="#style/inputNumbers"
android:layout_width="wrap_content"
app:layout_gravity="fill_horizontal"
/>
........
The content of Input numbers is
<style name="inputNumbers">
<item name="android:padding">10dp</item>
</style>
any ideas?
Given the problem is how you're using the paddings I'd recommend to take a look at the widget style (the Holo variation) if you want to change the default look:
...
<style name="Widget.NumberPicker">
<item name="android:internalLayout">#android:layout/number_picker</item>
<item name="android:orientation">vertical</item>
<item name="android:fadingEdge">vertical</item>
<item name="android:fadingEdgeLength">50dip</item>
</style>
...
<style name="Widget.Holo.NumberPicker" parent="Widget.NumberPicker">
<item name="android:internalLayout">#android:layout/number_picker_with_selector_wheel</item>
<item name="android:solidColor">#android:color/transparent</item>
<item name="android:selectionDivider">#android:drawable/numberpicker_selection_divider</item>
<item name="android:selectionDividerHeight">2dip</item>
<item name="android:selectionDividersDistance">48dip</item>
<item name="android:internalMinWidth">64dip</item>
<item name="android:internalMaxHeight">180dip</item>
<item name="virtualButtonPressedDrawable">?android:attr/selectableItemBackground</item>
</style>
I want to center a RelativeLayout which contains TextViews in a ScrollView but when I change to Landscape mode or even in portrait mode with a small screen, the button of the RelativeLayout is cutted... Have you any idea to center it without be cutted please??
Here my code:
<ScrollView
style="#style/scroll"
android:background="#drawable/first_body_shape" >
<RelativeLayout style="#style/relativeLay"
android:layout_gravity="center_vertical" >
<TextView
android:id="#+id/rg2"
style="#style/verset"
android:layout_below="#+id/rg1"
android:text="#string/rg_2" />
<TextView
android:id="#+id/rg3"
style="#style/textView_intro"
android:layout_below="#+id/rg2"
android:text="#string/rg_2_1" />
<TextView
android:id="#+id/rg4"
style="#style/verset"
android:layout_below="#+id/rg3"
android:text="#string/rg_3" />
<TextView
android:id="#+id/rg5"
style="#style/textView_intro"
android:layout_below="#+id/rg4"
android:text="#string/rg_3_1" />
<TextView
android:id="#+id/rg6"
style="#style/verset"
android:layout_below="#+id/rg5"
android:text="#string/rg_4" />
<TextView
android:id="#+id/rg7"
style="#style/textView_intro"
android:layout_below="#+id/rg6"
android:text="#string/rg_4_1" />
<TextView
android:id="#+id/rg8"
style="#style/textView_intro"
android:layout_below="#+id/rg7"
android:text="#string/rg_5" />
<TextView
android:id="#+id/rg1"
style="#style/textView_intro"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="#string/rg_1" />
</RelativeLayout>
</ScrollView>
styles.xml
<style name="scroll">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_marginBottom">10sp</item>
<item name="android:layout_marginLeft">10sp</item>
<item name="android:layout_marginRight">10sp</item>
<item name="android:layout_marginTop">50sp</item>
</style>
<style name="relativeLay">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>
<style name="verset">
<item name="android:layout_width">370sp</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_centerHorizontal">true</item>
<item name="android:paddingTop">10sp</item>
<item name="android:textSize">18sp</item>
<item name="android:textStyle">bold</item>
</style>
I'm not sure to understand your problem (i don't see any button in your code :o).
But have a look on this tutorial :
http://www.curious-creature.org/2010/08/15/scrollviews-handy-trick/
This is a sample TextView in XML, which will properly apply the style TextContactContactName to the TextView.
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/photo"
android:layout_alignTop="#id/photo"
android:paddingLeft="10dp"
android:text="First Last"
style="#style/TextContactContactName"
/>
Now, I have some other things to set on this element, which are not text related. As such I tried to move the TextContactContactName and apply it via "android:textAppearance"
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/photo"
android:layout_alignTop="#id/photo"
android:paddingLeft="10dp"
android:text="First Last"
android:textAppearance=#style/TextContactContactName"
/>
Unluckily, the text formatting is not being applied.
This is how the style (stored in res/values/styles-text.xml) looks like:
<style name="TextContactContactName">
<item name="android:textSize">24sp</item>
<item name="android:textColor">#333333</item>
<item name="android:shadowColor">#ffffff</item>
<item name="android:shadowDx">0</item>
<item name="android:shadowDy">1</item>
<item name="android:shadowRadius">1</item>
</style>
Am I using the textAppearance tag wrong?
I tested on Android 2.2 - HTC Desire.
Ok, looks like my fault. I had made a quick test:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text styled using 'style'."
style="#style/UiTestTextView"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text styled using 'textAppearance'."
android:textAppearance="#style/UiTestTextView"
/>
and the styles-text.xml:
<style name="UiTestTextView">
<item name="android:textColor">#ff0000</item>
<item name="android:textSize">16sp</item>
<item name="android:shadowColor">#ffffff</item>
<item name="android:shadowDx">1</item>
<item name="android:shadowDy">2</item>
<item name="android:shadowRadius">3</item>
</style>
The key thing is to remember that shadow* elements are not text properties. And as such will not be applied via textAppearance.
I'm going to ask on the Android Developers Mailing list if this is desired behavior.
I filed a bug report on this issue. I think I got the standard reply "the shadow is not considered part of the text appearance".
http://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=35887