gpt4 book ai didi

java - 扩展输入的 EditText 宽度

转载 作者:行者123 更新时间:2023-12-01 15:35:15 24 4
gpt4 key购买 nike

我是一名菜鸟程序员,所以我问的可能是一些非常基本的东西 - 尽管我无法使用搜索引擎找到答案。

问题 1:

我需要每个 EditText 来扩展其输入宽度。我尝试添加 android:inputType="textCapSentences" 并将宽度设置为每个 View 中的“Wrap_content” - 但是,它似乎不起作用,而且它删除了给出的提示。

这是我的代码:

      <LinearLayout 
android:id="@+id/namebar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:paddingRight="20.0dip"
android:paddingLeft="20.0dip"
android:paddingTop="20.0dip"
android:layout_above="@+id/tavleframe"
>
<EditText
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="@drawable/tavle"
android:gravity="center"
android:hint="@string/name_text"
android:textColor="#ffffffff"
Imageview.Scaletype="fill_parent"
android:inputType="textCapSentences"
/>

<EditText
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="@drawable/tavle"
android:gravity="center"
android:hint="@string/name_text"
android:textColor="#ffffffff"
Imageview.Scaletype="fill_parent"
android:inputType="textCapSentences"/>

<EditText
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="@drawable/tavle"
android:gravity="center"
android:hint="@string/name_text"
android:textColor="#ffffffff"
Imageview.Scaletype="fill_parent"
android:inputType="textCapSentences"/>

<EditText
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="@drawable/tavle"
android:gravity="center"
android:hint="@string/name_text"
android:textColor="#ffffffff"
Imageview.Scaletype="fill_parent"
android:inputType="textCapSentences"/>

<EditText
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="@drawable/tavle"
android:gravity="center"
android:hint="@string/name_text"
android:textColor="#ffffffff"
Imageview.Scaletype="fill_parent"
android:inputType="textCapSentences"/>
</LinearLayout>

最佳答案

这将有助于了解“它似乎不起作用”的意思,但我有一个想法。您将宽度设置为 wrap_content,但还将 layout_weight 设置为 1。这会将所有多余的水平空间等量分配给每个 EditText.只需从每个 EditText 中删除 android:layout_weight 属性即可。

我也不明白你所说的“它删除了给出的提示”是什么意思。

关于java - 扩展输入的 EditText 宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8962583/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com