gpt4 book ai didi

android - 如何在页面加载时从 TextInputLayout 中移除焦点?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:32:23 25 4
gpt4 key购买 nike

当这个 xml 加载到 fragment 中时,焦点直接转到第二个编辑文本,我希望编辑文本应该集中在触摸它上。我想使用我自己的颜色来提示和输入文本。非常感谢任何帮助。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="23dp">

<TextView
android:id="@+id/basic_details_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/basic_details"
android:textSize="16sp"
android:paddingLeft="0dp"
android:textColor="@color/basic_details_gray"
android:textStyle="normal"
android:typeface="monospace"
android:includeFontPadding="false"
android:layout_alignParentLeft="true"
/>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/container_first"
android:layout_below="@+id/basic_details_heading"
android:paddingLeft="0dp"
>

<!-- <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/profile_created_for"
android:id="@+id/sub_head_one"
android:textStyle="normal"
android:textColor="@color/login_background"
android:textSize="12sp"
android:paddingLeft="0dp"
android:paddingTop="0dp"
android:visibility="gone"
android:includeFontPadding="false"
android:layout_alignParentLeft="true"
/>-->
<android.support.design.widget.TextInputLayout
android:id="@+id/profile_created_for"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>

<EditText
android:id="@+id/edit_text_profile_created_for"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="-4dp"
android:textSize="15sp"
android:textColor="@color/black"
android:textStyle="normal"
android:hint="Profile Created For"
android:focusable="false"/>

</android.support.design.widget.TextInputLayout>

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/nav_next"
android:layout_alignParentRight="true"
android:paddingTop="20dp"
android:id="@+id/profile_created_for_arrow"
/>


<android.support.design.widget.TextInputLayout
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/profile_created_for"
android:focusableInTouchMode="true"
>

<EditText
android:id="@+id/edit_text_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="-4dp"
android:textSize="15sp"
android:textColor="@color/black"
android:textStyle="normal"
android:hint="Name"
/>

</android.support.design.widget.TextInputLayout>


</RelativeLayout>


</RelativeLayout>

最佳答案

试试这个:在您的 xml 中添加一个虚拟对象,就在您的文本布局之前,以便它可以占用焦点。

<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="0px"
android:layout_height="0px"/>

关于android - 如何在页面加载时从 TextInputLayout 中移除焦点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35558493/

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