当这个xml加载到片段中时,焦点直接转到第二个编辑文本,我希望编辑文本应该专注于触摸它。我想用自己的颜色来暗示和在其上打字的文字。任何帮助都非常感激。
select p.prod_id, p.prod_name, p.prod_a_id, p.prod_b_id,
t.key_id, t.key_word, t.kay_country, t.dat_date,
t.dat_rank_a, t.dat_rank_b, t.dat_traffic_a, t.dat_traffic_b
from
(
select
k.key_id, k.key_word, k.kay_country, d.dat_date, d.dat_rank_a,
d.dat_rank_b, d.dat_traffic_a, d.dat_traffic_b,
row_number() over (partition by dat_id order by dat_date desc) as 'RowNum'
from keywords as k
inner join
data as d on k.key_id = d.dat_id
) as t
inner join
prods as p on t.key_prod = p.prod_id
where tmp.RowNum <=2
答案 0 :(得分:19)
尝试这样做:在文本布局之前的xml中添加一个虚拟对象,以便它可以消耗焦点。
<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="0px"
android:layout_height="0px"/>
答案 1 :(得分:11)
在TextInputLayout的父视图中添加属性android:focusableInTouchMode="true"
,如下所示
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
............>
<android.support.v7.widget.AppCompatEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
............/>
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
答案 2 :(得分:5)
在根视图(TextInputLayout)中使用以下属性:(您要禁用它)
android:focusableInTouchMode="true"
答案 3 :(得分:0)
我尝试在您不想自动聚焦的Edittext之前添加另一个EditText,它有效
<EditText
android:layout_width="0dp"
android:layout_height="0dp" />
<android.support.design.widget.TextInputLayout
android:id="@+id/NghiPhep_TextInputLayout_GhiChu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintTextAppearance="@style/TextHintLabel"
android:layout_marginTop="5dp"
android:focusableInTouchMode="true"
>
<EditText
android:id="@+id/NghiPhep_txt_GhiChu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/colorPrimaryDark"
android:hint="Ghi chú"
android:fontFamily="@font/arial_rounded"
android:inputType="textMultiLine"
android:singleLine="false"
android:textSize="18sp"/>
</android.support.design.widget.TextInputLayout>