Android:如何设置微调框的最大尺寸? [英] Android: How to set the maximum size of a Spinner?

查看:92
本文介绍了Android:如何设置微调框的最大尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的布局

<?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的视图.但是,当我选择一个较大的元素时,文本字段会向右推出.有什么方法可以设置微调器的最大尺寸,以便在选择元素之后,用省略号("...")或类似的东西会缩短选择范围?

I inflate this layout as an AlertDialog's view. But when I pick a large element, the text fields get pushed out to the right. Is there any way to set the maximum size of the spinner so after choosing an element, it shortens the choice with an ellipsis ("...") or something?

推荐答案

android:layout_width="wrap_content"集具有android:layout_width="wrap_content"的大小由其内容确定.如果您希望将内容椭圆化,则在创建行视图时由SpinnerAdapter决定.

The size of a Spinner set have android:layout_width="wrap_content" is determined by its content. If you want things ellipsized, that's up to you in your SpinnerAdapter, when you create your row Views.

或者,硬连接大小固定的android:layout_width.

Or, hard-wire an android:layout_width that is fixed in size.

或者,不使用LinearLayout,而是使用RelativeLayout并构造规则,以使Spinner通过将其固定在屏幕的左侧和左侧来占用该行上的剩余空间.第一个EditText中的第一个.虽然我不确定100%如果内容太大,那会发生什么-它可能会被截断.

Or, instead of using LinearLayout, use RelativeLayout and structure your rules such that the Spinner takes up the remaining space on the row, by anchoring it to the left side of the screen and to the left side of the first EditText. Though I'm not 100% certain what then happens if the content is too big -- it probably just gets truncated.

这篇关于Android:如何设置微调框的最大尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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