1

在我的應用程序中,我製作了一個搜索字段,它與某個過濾器類似。所以我想實現我的搜索頁面一些類似於這個圖像。 enter image description here我試圖搜索它,但無法找到這樣scrooling文本視圖與選擇框稱爲和選擇下面的框中刪除標誌哪種佈局是那樣的?請幫助我爲這樣的事情和任何圖書館設計什麼樣的佈局,以及他們叫什麼。帶有芯片類型可選框的Android文本視圖

感謝

+0

所以你想要像textviews芯片。意味着不同的文字包裹在一個帶有封閉符號或負號的矩形框中。 ?我對麼 ? –

+0

是@Ragu Swaminathan –

+0

下面的答案是否適合您? –

回答

0

UPDATE

檢查這個https://github.com/whilu/AndroidTagView

一個TagView庫爲Android。自定義您的&拖動效果。

build.gradle文件。

dependencies { 
    compile 'co.lujun:androidtagview:1.0.3' 
} 

enter image description here

+0

感謝您的回答。實際上我正在尋找的不是搜索框中顯示的這些芯片,而是希望它們在搜索框下方單獨顯示,以便用戶可以滾動並選擇也可以代替使用此lib搜索 –

+0

,用戶也可以搜索並選擇該標籤那是默認功能 –

+0

是你的問題解決了嗎?@AnkeshkumarJaisansaria –

3

我知道你是想用自己的風格創建的複選框。您可以通過幾個XML定義來實現這一點。檢查我使用的代碼在一個應用程序:

首先,定義複選框:

<CheckBox 
    android:id="@+id/btn_team_home" 
    android:layout_width="0dp" 
    android:layout_height="match_parent" 
    android:layout_gravity="center_vertical" 
    android:layout_weight="0.4" 
    android:background="@drawable/selector_match_team" 
    android:button="@null" 
    android:ellipsize="end" 
    android:gravity="center" 
    android:maxLines="2" 
    android:minLines="2" 
    android:textColor="@color/selector_btn_matches_text"/> 

這裏最重要的屬性是「機器人:背景」

背景屬性包含一個選擇指定觀點如何對不同事件做出反應。您可以在下面看到res/drawable/selector_match_team的代碼。另外不要忘記設置android:button =「@ null」。我的複選框定義中的其他屬性對您的情況並不重要。

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<item 
    android:state_checked="true"> 
    <shape android:shape="rectangle"> 
     <corners android:radius="@dimen/btn_match_radius"/> 
     <!--<stroke--> 
     <!--android:width="1dip"--> 
     <!--android:color="@color/match_picker_match_border_checked"/>--> 
     <gradient 
      android:endColor="@color/match_picker_match_bg_checked" 
      android:startColor="@color/match_picker_match_bg_checked"/> 
    </shape> 
</item> 

<item 
    android:state_checked="false"> 
    <shape android:shape="rectangle"> 
     <corners 
      android:radius="@dimen/btn_match_radius"/> 
     <!--<stroke--> 
     <!--android:width="1dip"--> 
     <!--android:color="@color/match_picker_match_border_unchecked"/>--> 
     <gradient 
      android:endColor="@color/match_picker_match_bg_unchecked" 
      android:startColor="@color/match_picker_match_bg_unchecked"/> 
    </shape> 
</item> 

在這裏你可以看到,第一個項目是國家背景「檢查」。它包含具有圓角和背景色的矩形形狀(漸變屬性)。在你的情況下,因爲你想要在你的按鈕周圍的邊框,所以應用註釋的「中風」。顏色和尺寸並不重要,所以我沒有在這裏指定它們。

由於您的基本視圖已經是一個複選框,並且您實現了自己的選擇器,所以您不必手動編寫任何代碼來處理背景/檢查狀態。

+0

如何更改複選框的文本顏色? –

+1

您可以更改android:textColor =「@ color/selector_btn_matches_text」 – vanomart

相關問題