2017-12-05 17 views
-1

Ich habe eine Aktivität, die einige Elemente wie ImageViews, TextViews, EditTexts und Buttons hat. Alles zeigt OK, aber zwei TextViews sind nicht sichtbar, wenn ich die App starte. Die Vorschau ist OK, aber wenn ich die App in meinem Telefon öffne, wird sie nicht angezeigt.TextView wird nicht in einer Aktivität angezeigt

Das ist mein XML-Code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       xmlns:tools="http://schemas.android.com/tools" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical" 
       tools:context="com.construct.v2.activities.auth.PasswordChangeActivity"> 
    <!--<include android:id="@+id/toolbar" layout="@layout/toolbar_simple" />--> 
    <ProgressBar 
    android:id="@+id/progressBar" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_margin="@dimen/mm_margin" 
    android:layout_gravity="center" 
    android:visibility="gone"/> 

    <RelativeLayout 
     android:id="@+id/contentLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:paddingLeft="24dp" 
     android:paddingRight="24dp" 
     android:paddingTop="80dp"> 
    <ImageView 
     android:id="@+id/change_lock" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/change_pass" 
     android:layout_centerHorizontal="true"/> 

    <TextView 
     android:id="@+id/title" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="20sp" 
     android:fontFamily="sans-serif-medium" 
     android:textStyle="normal" 
     android:textColor="#00596f" 
     android:lineSpacingExtra="2sp" 
     android:layout_centerHorizontal="true" 
     android:layout_below="@id/change_lock" 
     tools:text="@string/change_password" 
     /> 

    <TextView 
     android:id="@+id/subtitle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="16sp" 
     android:fontFamily="sans-serif" 
     android:textStyle="normal" 
     android:textColor="#555555" 
     android:lineSpacingExtra="4sp" 
     android:layout_below="@+id/title" 
     android:layout_centerHorizontal="true" 
     android:paddingTop="15dp" 
     tools:text="@string/new_password_text" 
     /> 

    <TextView 
     android:id="@+id/fill_password" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/subtitle" 
     android:textColor="@color/construct_red" 
     android:paddingTop="15dp" 
     /> 

    <EditText 
      android:id="@+id/password" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:hint="@string/password" 
      android:textSize="16dp" 
      android:textColorHint="#b1b1b1" 
      android:layout_below="@+id/fill_password" 
      android:backgroundTint="#00596f" 
      android:textColor="#00596f" 
      android:textCursorDrawable="@drawable/color_cursor" 
      android:inputType="textPassword" 
      /> 
    <Button 
     android:id="@+id/saveButton" 
     android:layout_width="220dp" 
     android:layout_height="40dp" 
     android:text="@string/save" 
     android:textSize="14dp" 
     android:gravity="center" 
     android:layout_centerHorizontal="true" 
     android:textColor="#b1b1b1" 
     android:background="#e3e3e3" 
     android:paddingLeft="56dp" 
     android:paddingRight="56dp" 
     android:layout_below="@+id/password" 
     android:layout_marginTop="32dp"/> 
    </RelativeLayout> 
</RelativeLayout> 

Dies ist die Vorschau von Android Studio ist:

enter image description here

Und das ist die App in meinem Handy läuft:

enter image description here

Antwort

4

Sie stellen Text ein mit tools

tools:text="@string/new_password_text" 

Änderung:

android:text="@string/new_password_text" 
+0

Dank! Das hat das Problem behoben! –

0

Ich habe gerade das Problem. Ich benutze Zeplin als Werkzeug für die Bildschirmgestaltung und erstelle normalerweise den XML-Code für die Elemente. Statt:

tools:text="@string/new_password_text" 

ich geändert:

android:text="@string/new_password_text" 
Verwandte Themen