【问题标题】:Very Big NumberPicker非常大的数字选择器
【发布时间】:2013-12-13 08:08:16
【问题描述】:

这是我的布局 XML 文件:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <ScrollView
        android:id="@+id/scroller"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        >

        <TableLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <TableRow
                android:id="@+id/tableRow1"
                android:layout_width="fill_parent"
                android:layout_height="50dp" >

                <RadioButton
                    android:id="@+id/radioButton1"
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:drawableRight="@android:drawable/btn_radio"
                    android:button="@null"
                    android:textSize="12sp"
                    android:text="RadioButton" />

                <NumberPicker
                    android:id="@+id/numberPicker1"
                    android:layout_width="wrap_content"
                    android:layout_height="50dp" />

            </TableRow>

            <TableRow
                android:id="@+id/tableRow2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

            </TableRow>

            <TableRow
                android:id="@+id/tableRow3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >
            </TableRow>

            <TableRow
                android:id="@+id/tableRow4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >
            </TableRow>
        </TableLayout>

    </ScrollView>



</RelativeLayout>

这里有一个大问题。请看下图,看看NumberPicker 有多大!

我需要的NumberPickers 如下所示。

我尝试设置高度并固定,但似乎没有太大效果。此设计适用于手机和平板电脑。如上图所示,如何使这个 NumberPicker 变小?

【问题讨论】:

  • 似乎 50dp 的高度对于 NumberPicker 小部件来说是不够的。我认为您必须编写自定义 NumberPicker 视图以适应这么小的区域。

标签: java android xml user-interface android-fragments


【解决方案1】:

使用

android:scaleX="0.5"
android:scaleY="0.5"

并使用这些值。

【讨论】:

  • 谢谢。但是当被调用时,它们会留下一个巨大的填充
  • 是的,它会留下一个填充,我实际上不知道如何缩放整个视图,而不仅仅是选择器。我会试着检查一下。
【解决方案2】:

您可以创建自己的自定义 numberpickerview。或者您可以使用 Wheelpicker(与 iphone 相同),这样设计会很有趣。

【讨论】:

    猜你喜欢
    • 2011-08-09
    • 2011-05-14
    • 1970-01-01
    • 2023-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-10
    • 1970-01-01
    相关资源
    最近更新 更多