简体   繁体   English

如何在Android的ScrollView中使textview焦点像Edittext Focus一样?

[英]How to make textview focus like Edittext Focus in ScrollView in android?

I am developing application with some edittext's and some textviews. 我正在使用一些edittext和一些textview开发应用程序。 Those all are in scrollview. 这些全都在scrollview中。 When touch on edittext the soft key is appearing and the view automatically adjusted. 触摸edittext时,将显示软键,并且视图将自动调整。 The selected edit text is appearing above the soft key. 所选的编辑文本显示在软键上方。 And when click on textview i am showing some hidden view(Linear layout contains 3 buttons) that covers my selected textview field. 当单击textview时,我会显示一些隐藏的视图(线性布局包含3个按钮),该视图覆盖了我选择的textview字段。 I am not getting how can i give the same functionality like edittext which can be move my selected textview to above my custom popup. 我没有得到如何提供与edittext相同的功能,可以将所选的textview移至自定义弹出窗口上方。 Please suggest me is there any way to give the focus function like edittext for textview in scrollview. 请建议我有什么办法可以给焦点功能,例如editview的scrollview中的textview。

Thanks in advance. 提前致谢。

EditText and TextView are quite similar. EditTextTextView非常相似。 The only difference I see hard-coded into EditText.java is to set the editable default to true, which you've set manually. 我看到硬编码到EditText.java中的唯一区别是将可编辑的默认值设置为true,这是您手动设置的。 Other than that, the EditText style is: 除此之外, EditText 样式是:

<style name="Widget.EditText">
    <item name="android:focusable">true</item>
    <item name="android:focusableInTouchMode">true</item>
    <item name="android:clickable">true</item>
    <item name="android:background">@android:drawable/edit_text</item>
    <item name="android:textAppearance">?android:attr/textAppearanceMediumInverse</item>
    <item name="android:textColor">@android:color/primary_text_light</item>
    <item name="android:gravity">center_vertical</item>
</style>

refered from Disable EditText editability and focus (like TextView) 禁用EditText可编辑性和焦点(如TextView)中引用

and TextView is: TextView是:

<style name="Widget.TextView">
    <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
</style>

My guess is that @android:drawable/edit_text is the source of the orange box. 我的猜测是@android:drawable/edit_text是橙色框的来源。 Indeed, it contains : 实际上, 它包含

<item android:state_pressed="true" android:drawable="@drawable/textfield_pressed"/>

The simplest way might be to set its background to the default one: 最简单的方法可能是将其背景设置为默认背景:

android:background="@android:drawable/textfield_default"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM