2017-09-19 1 views
1

Ich kann nach dem Erstellen der App nichts (die Textansichten) sehen. Nur das Hintergrundbild wird angezeigt und sonst nichts. Alles läuft, aber trotzdem erscheinen die Texte nicht. Unter dem Scrollview mache ich ein lineares Layout und darunter gibt es mehrere andere Textansichten. Aber keine von ihnen wird tatsächlich angezeigt, wenn ich die App baue. Wie kann ich alles unter dem scrollview sichtbar machen? Hier ist mein Code:Nichts anzeigen (Textansichten) in der Bildlaufansicht

`

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/blck" 
    android:weightSum="1" 

    tools:context="com.gnulinuxusersgroup.nitdgp.glug.faqs" 
    app:layout_collapseParallaxMultiplier="1.0"> 

    <!-- TODO: Update blank fragment layout --> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 



    <TextView 
      android:layout_width="match_parent" 
      android:layout_height="75dp" 
      android:id="@+id/F" 
      tools:text="@string/faq" 
      tools:textColor="#ffffff" 
      tools:textSize="100px" 

      android:textAppearance="@style/TextAppearance.AppCompat" 
      android:layout_weight="0.02" /> 
     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="130px" 
      tools:text="@string/hwr" 
      tools:textColor="#fff" 
      tools:textSize="40px" 
      tools:textStyle="bold" 
      /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="300px" 
      tools:text="@## `string/hwr2" 
      tools:textColor="#fff" 
      tools:textSize="40px" 
      /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="130px" 
      tools:text="@string/foss" 
      tools:textColor="#fff" 
      tools:textSize="40px" 
      tools:textStyle="bold" 
      /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="269dp" 
      tools:text="@string/foss2" 
      tools:textColor="#fff" 
      tools:textSize="40px" /> 
     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="130px" 
      tools:text="@string/work1" 
      tools:textColor="#fff" 
      tools:textSize="40px" 
      tools:textStyle="bold" 
      /> 
     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="300px" 
      tools:text="@string/work2" 
      tools:textColor="#fff" 
      tools:textSize="40px" 
      /> 
     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="130px" 
      tools:text="@string/free" 
      tools:textColor="#fff" 
      tools:textSize="40px" 
      tools:textStyle="bold" 
      /> 
     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="300px" 
      tools:text="@string/free2" 
      tools:textColor="#fff" 
      tools:textSize="40px" 
      /> 
     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="46dp" 
      tools:text="@string/git" 
      tools:textColor="#fff" 
      tools:textSize="40px" 
      tools:textStyle="bold" 
      /> 
     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="300px" 
      tools:text="@string/git2" 
      tools:textColor="#fff" 
      tools:textSize="40px" 
      /> 
     <TextView 
      android:layout_width="394dp" 
      android:layout_height="50dp" 
      tools:text="@string/gsoc" 
      tools:textColor="#fff" 
      tools:textSize="40px" 
      tools:textStyle="bold" 
      /> 
     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="700px" 
      tools:text="@string/gsoc2" 
      tools:textColor="#fff" 
      tools:textSize="40px" 
      /> 
    </LinearLayout> 
</ScrollView> 

`

Antwort

0

Ersetzen Sie Ihre verschiedenen tools: Attribute mit android: Attributen.

Der Namespace tools wird verwendet nur von dem Android Studio Design-Vorschaufenster. Auf diese Weise können Sie beispielsweise Platzhaltertext angeben, so dass Sie sehen können, wie es aussehen würde, ohne dass tatsächlich sichtbarer Text angegeben wird, der in der realen Welt möglicherweise nicht richtig angezeigt wird.

Nehmen Sie das Textview:

<TextView 
     android:layout_width="match_parent" 
     android:layout_height="130px" 
     tools:text="@string/hwr" 
     tools:textColor="#fff" 
     tools:textSize="40px" 
     tools:textStyle="bold" 
     /> 

Da alle in den letzten vier Attribute verwenden, um die tools Namespace, werden sie nicht tatsächlich keine Auswirkungen haben, wenn Sie die Anwendung ausführen. Dies ist das gleiche wie das geschrieben zu haben (soweit Ihre laufenden App betroffen ist):

<TextView 
     android:layout_width="match_parent" 
     android:layout_height="130px" 
     /> 

Vorerst nur ersetzen die alle tools Namespaces mit android:

<TextView 
     android:layout_width="match_parent" 
     android:layout_height="130px" 
     android:text="@string/hwr" 
     android:textColor="#fff" 
     android:textSize="40px" 
     android:textStyle="bold" 
     /> 
0

zum Ben P Hinzufügen Antwort, die möglichen Täter sind:

  1. Überprüfen Sie Ihre Hintergrundfarbe, wie Sie Textfarbe auf Weiß stellen Sie sicher, dass sie Kontrast haben.
  2. Da die Ausrichtung von LinearLayout Vertikal ist und Sie Gewichtssumme verwenden, ist es besser, layout_height="0dp" im Falle der horizontalen Ausrichtung Breite wie 0dp zu haben.
  3. Wenn Sie winsum angeben, stellen Sie sicher, dass layout_weight den Wert addiert. Sie können das Gewicht weglassen, mit dem das System die Prozentsätze automatisch berechnet, indem die einzelnen Widgets in der Gruppe berücksichtigt werden.
  4. Auch wenn die Widgets Textansicht sind, können Sie nicht viel Unterschied in der vertikalen Ausrichtung sehen, also habe ich die untere Xml Ausrichtung auf horizontal geändert, so dass während des Betriebs auf dem Gerät oder im Layout-Vorschaufenster den Gewichtsunterschied deutlich zu sehen.

    <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    > 
    <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/F" 
        android:text="hello1" 
        android:textSize="60px" 
        android:textAppearance="@style/TextAppearance.AppCompat" 
        android:layout_weight="1" /> 
    <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="hello1r" 
        android:textSize="40px" 
        android:textStyle="bold" 
        android:layout_weight="4" 
        /> 
    
    <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="hello3" 
        android:layout_weight="1" 
        android:textSize="40px" 
        /> 
    
    <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="hello4" 
        android:layout_weight="2" 
        android:textSize="40px" 
        android:textStyle="bold" 
        /> 
    
    <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_weight="2" 
        android:text="hello5" 
        android:textSize="40px" /> 
    

Verwandte Themen