2016-12-30 85 views
1

我的编辑文本显示提示,但它不显示光标和打字区域。我该怎么做才能显示光标和区域,而不仅仅是提示?edittext光标和编辑区域不显示

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/activity_main_menu" 
android:layout_width="match_parent" 
android:layout_height="fill_parent" 
android:background="@drawable/numberborder" 
tools:context="com.example.light.primenumbercompanion.MainMenu"> 
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 
    <TextView 
     android:id="@+id/checker" 
     android:layout_width="230dp" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:textColor="@color/black" 
     android:textStyle="bold" 
     android:layout_marginTop="37dp" 
     android:layout_marginLeft="20dp" 
     android:layout_marginBottom="37dp" 
     android:text="@string/checker" 
     android:textSize="20sp"/> 
    <TextView 
     android:id="@+id/checkerQeustion" 
     android:layout_below="@id/checker" 
     android:layout_width="230dp" 
     android:layout_height="wrap_content" 
     android:textColor="@color/black" 
     android:textStyle="bold" 
     android:layout_marginLeft="20dp" 
     android:layout_marginBottom="5dp" 
     android:text="@string/checkerQuestion"/> 
    <EditText 
     android:layout_width="200dp" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="20dp" 
     android:layout_marginBottom="5dp" 
     android:id="@+id/checkerInput" 
     android:layout_below="@id/checkerQeustion" 
     android:hint="@string/checkerInput" 
     android:inputType="number"/> 


</RelativeLayout> 

我觉得用户将不知道在哪里输入数量

+0

没有什么错,我在这里找到。我可以看到光标和默认的edittext下划线边框。你能添加截图吗?它可能是'@ drawable/numberborder'造成背景与默认的edittext背景混淆。 –

回答

1

。在你的活动没有任何问题复制我的代码我碰到你的代码,它工作正常,虽然你是不关闭滚动视图关闭它或者你忘记发送关闭滚动视图的代码并发送你的Java所以我会验证它,所以没有问题。

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/activity_main_menu" 
android:layout_width="match_parent" 
android:layout_height="fill_parent" 
> 
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 
    <TextView 
     android:id="@+id/checker" 
     android:layout_width="230dp" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:textColor="#000000" 
     android:textStyle="bold" 
     android:layout_marginTop="37dp" 
     android:layout_marginLeft="20dp" 
     android:layout_marginBottom="37dp" 
     android:text="Heading text" 
     android:textSize="20sp"/> 
    <TextView 
     android:id="@+id/checkerQeustion" 
     android:layout_below="@id/checker" 
     android:layout_width="230dp" 
     android:layout_height="wrap_content" 
     android:textColor="#000000" 
     android:textStyle="bold" 
     android:layout_marginLeft="20dp" 
     android:layout_marginBottom="5dp" 
     android:text="textview"/> 
    <EditText 
     android:layout_width="200dp" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="20dp" 
     android:layout_marginBottom="5dp" 
     android:id="@+id/checkerInput" 
     android:layout_below="@id/checkerQeustion" 
     android:hint="testedittext" 
     android:inputType="number"/> 


</RelativeLayout> 
</ScrollView> 
+0

谢谢,预览愚弄了我! –

0

如果你想改变光标的颜色在你的的EditText您可以在XML中添加下面一行在你的EditText标签

android:textCursorDrawable="@drawable/cursor_color" 

cursor_color.xml

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <size android:width="3dp" /> 
    <solid android:color="#000000" /> 
</shape> 

我的默认颜色是黑色,您可以随意更改颜色。 试试吧,让我知道它是否适合你。

+1

你可能会说你的光标颜色和背景是“白色”一样,所以它不会在那里显示。 @sina rafiei –