5

これが私のレイアウトです

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
          android:layout_width="fill_parent" android:id="@+id/LinearLayout01"
         android:layout_height="wrap_content">

    <Spinner android:text="@+id/AutoCompleteTextView01"
                       android:id="@+id/Spinner01"
                       android:layout_width="wrap_content"
                       android:layout_height="wrap_content"
                       android:width="130dp"></Spinner>
    <EditText android:layout_height="wrap_content"
              android:layout_width="wrap_content"
             android:id="@+id/Chapter" android:width="30dp"></EditText>
    <TextView android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/TextView01" android:text=":"></TextView>
    <EditText android:layout_height="wrap_content"
              android:layout_width="wrap_content" android:id="@+id/Verse"
              android:width="40dp"></EditText>

</LinearLayout>

このレイアウトをAlertDialogのビューとして膨らませます。しかし、大きな要素を選択すると、テキストフィールドが右に押し出されます。スピナーの最大サイズを設定して、要素を選択した後、省略記号( "...")などで選択を短縮する方法はありますか?

4

3 に答える 3

5

カスタムアダプタを使用する必要はありません。android.R.layout.simple_spinner_itemを使用して、楕円マーキーから終了楕円に変更します。次に、新しい変更レイアウトファイルをレイアウトIDとして設定するか、このレイアウトファイルを使用します

<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/text1"
    style="?android:attr/spinnerItemStyle"
    android:singleLine="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingRight="10dp"
    android:ellipsize="end" />
于 2013-07-23T12:38:25.260 に答える
4

Spinnerセットのサイズは、android:layout_width="wrap_content"その内容によって決まります。物事を楕円形にしたい場合はSpinnerAdapter、行ビューを作成するときに、それはあなた次第です。

android:layout_widthまたは、サイズが固定されているanを配線します。

または、を使用する代わりに、をLinearLayout使用して、画面の左側と最初のの左側にアンカーすることにより、行の残りのスペースを占めるRelativeLayoutようにルールを構成します。コンテンツが大きすぎるとどうなるかは100%わかりませんが、おそらく切り捨てられるだけです。SpinnerEditText

于 2010-03-05T23:40:43.973 に答える
1

問題を解決するには、スピナーandroid:background ="@null"を設定します。これにより、ドロップダウンアイコンの表示も非表示になります

于 2019-09-20T09:26:45.043 に答える