在Android文本画廊? [英] Text Gallery on Android?

查看:144
本文介绍了在Android文本画廊?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个画廊的的TextView 实现下面的图片上段控制器。我可以通过ApiDemo的库示例实现它,但我落后于画廊的外观和感觉。

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.

我试图让使用2种方式。具有以下特点:

I have tried to get using 2 ways. that are:

  1. 图库视图
  2. 横向滚动型
  1. Gallery View
  2. horizontal ScrollView

在输出中获得是在下面的图片:

The ouput getting is in the below image:

我有问题上都得到适当的输出。

I have Problem on Both to get the proper output.

在相册模式,

  • 在不能改变选择的背景 Item.and使我们圆角。
  • 在选定的项目涉及到的屏幕会自动的水平中心。
  • can not Change Background of Selected Item.and make it us rounded corner.
  • Selected Item comes to the center horizontal of the Screen Automatically.

在水平视图,

  • 的TextView 的数量很大更为复杂。
  • 在无法找到类似于在按项目的方式。如果我有使用开关的情况下。在previous问题就来了。
  • 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.

推荐答案

这个地方在可绘text_selector.xml

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

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

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>

这里是TextView的膨胀

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"
        />

获取的风格了。应放置在RES /衣被合计/ styles.xml

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>

这篇关于在Android文本画廊?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆