I have a gallery with the TextView to achieve the segment controller on the image below. I can achieve it by the ApiDemo's Gallery Example but I am lagging on the look and feel of the gallery.
I want to do the backgrounds, Selected/deselected and selected item won't be cone to the center of the screen.
Any Idea or Articles are most Thankful.
image http://www.freeimagehosting.net/uploads/cce47da96开发者_高级运维9.png
I have tried to get using 2 ways. that are:
- Gallery View
- horizontal ScrollView
The ouput getting is in the below image:
image http://www.freeimagehosting.net/uploads/b4c1be5924.png
I have Problem on Both to get the proper output.
In Gallery View,
- can not Change Background of Selected Item.and make it us rounded corner.
- Selected Item comes to the center horizontal of the Screen Automatically.
In horizontal View,
- More Complicated when the textView's number is large.
- Can not find a way similar to On Click Item. if i have use switch case. the previous problem comes again.
place this in drawables text_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/round" />
    <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/round" />
    <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/round_selected" />
    <item android:drawable="@drawable/round" />
</selector>
round.xml
    <?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle"> 
     <gradient android:startColor="#FFEF95" android:endColor="#FFEF95"   
            android:angle="270"/> 
<corners android:bottomRightRadius="14dp" android:bottomLeftRadius="14dp" 
     android:topLeftRadius="14dp" android:topRightRadius="14dp"/> 
</shape>
round_selected.xml
<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle"> 
     <gradient android:startColor="#F6A110" android:centerColor="#FFEF95" android:endColor="#F6A110"   
            android:angle="270"/> 
<corners android:bottomRightRadius="14dp" android:bottomLeftRadius="14dp" 
     android:topLeftRadius="14dp" android:topRightRadius="14dp"/> 
</shape>
And here is the textview to inflate
 <TextView    
        android:id="@+id/perioxi_select" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Select Area"
         android:gravity="center_vertical|center_horizontal"
         android:background="@drawable/text_selector"
         android:minHeight="60dp"
         style="@style/FirstText"   
         android:layout_weight="1"
        />
Get the style too. should be placed inside res/valus/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources> 
 <style name="FirstText"> 
        <item name="android:colorForeground">#f0f</item> 
        <item name="android:padding">4sp</item> 
        <item name="android:textSize">15sp</item> 
        <item name="android:textColor">#CC3300</item> 
        <item name="android:gravity">left</item> 
        <item name="android:typeface">monospace</item> 
        <item name="android:textStyle">bold</item> 
        <item name="android:colorBackground">#999</item> 
    </style> 
  </resources>
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论