2017-07-08 2 views
1

Wie für die meisten von Ihnen: Wir entwerfen unsere Bildschirme für unsere App in Photoshop und versuchen dann, sie in Visual Studio zu übertragen.Android, Layout: Wie bekomme ich meine Schaltfläche, um bestehendes Layout in axml zu überlagern?

Dies ist ein Screenshot von unserer App VON PHOTOSHOP:

enter image description here

Sie sich vorstellen können, je weiter wir fährt, desto schwieriger wird es. Der mittlere Bildschirm war einfach, aber der linke und der rechte - oh Junge ...

Wie auch immer, heute bin ich hier für den richtigen.

Wie Sie sehen können, gibt es diese Schlagzeilen wie: "Zeige uns Liebe für Asien". Diese ganze Box zeigt ein Foto, eine Überschrift, ein paar zusätzliche Infos UND: ein Profilbild.

Das Ganze ist eine Scrollansicht und die weißen Balken unter jeder Box sind eigentlich PNGs. Der Grund ist, dass wir sie auf jeder Plattform gleich groß haben müssen. Wie auch immer - das Profilbild überlappt die Bildbox und den weißen Teiler png zwischen den Bildboxen.

Und hier ist die Frage: Wie zur Hölle würden wir das in unsere axml implementieren?

Was ist der Bildschirm, das ist es in xml:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/layoutadventure" 
    android:background="@android:color/white" 
    android:orientation="vertical"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_weight="17" 
     android:layout_height="0dp" 
     android:background="#23313e" 
     android:orientation="horizontal"> 
     <ImageView 
      android:layout_width="0dp" 
      android:src="@drawable/sub_category_europe" 
      android:layout_gravity="center" 
      android:layout_height="wrap_content" 
      android:layout_weight="30" 
      android:id="@+id/imgSubchallenge" /> 
     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_weight="40" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 
      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_gravity="center|bottom" 
       android:id="@+id/txtSub" 
       android:layout_weight="60" 
       android:gravity="center|bottom" 
       android:text="Positive Thinking" 
       android:textColor="#FFFFFF" 
       android:textSize="18sp" 
       android:textStyle="bold|italic" /> 
      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="0dp" 
       android:layout_weight="5" 
       android:layout_gravity="top|center" 
       android:gravity="top|center" 
       android:src="@drawable/dotted_line_challenges" /> 
      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_weight="35" 
       android:layout_height="0dp" 
       android:orientation="vertical" /> 
     </LinearLayout> 
     <ImageView 
      android:layout_width="0dp" 
      android:src="@drawable/bar2" 
      android:layout_gravity="center" 
      android:layout_height="wrap_content" 
      android:layout_weight="5" /> 
     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_weight="25" 
      android:layout_height="match_parent" 
      android:orientation="horizontal"> 
      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_weight="50" 
       android:layout_height="match_parent" 
       android:orientation="vertical"> 
       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="30" 
        android:orientation="vertical" /> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="15" 
        android:text="Total" 
        android:textColor="#FFFFFF" 
        android:textSize="10sp" /> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="15" 
        android:text="Done" 
        android:textColor="#FFFFFF" 
        android:textSize="10sp" /> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="15" 
        android:text="Exp" 
        android:textColor="#FFFFFF" 
        android:textSize="10sp" /> 
       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="25" 
        android:orientation="vertical" /> 
      </LinearLayout> 
      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_weight="50" 
       android:layout_height="match_parent" 
       android:orientation="vertical"> 
       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="30" 
        android:orientation="vertical" /> 
       <TextView 
        android:id="@+id/totalChallenges" 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="15" 
        android:text="Total" 
        android:gravity="right" 
        android:textColor="#FFFFFF" 
        android:textSize="10sp" /> 
       <TextView 
        android:id="@+id/totalChallengesDone" 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="15" 
        android:text="Done" 
        android:gravity="right" 
        android:textColor="#FFFFFF" 
        android:textSize="10sp" /> 
       <TextView 
        android:id="@+id/totalXP" 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="15" 
        android:text="Exp" 
        android:gravity="right" 
        android:textColor="#FFFFFF" 
        android:textSize="10sp" /> 
       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="25" 
        android:orientation="vertical" /> 
      </LinearLayout> 
     </LinearLayout> 
     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="2" 
      android:orientation="vertical" /> 
    </LinearLayout> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="0.5" 
     android:orientation="vertical" /> 
    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="82.5" 
     android:scrollbars="none" 
     android:id="@+id/scrlview"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:id="@+id/linlayout" 
      android:orientation="vertical" /> 
    </ScrollView> 
</LinearLayout> 

Sie sehen also wohl das Dilemma: das Profilbild in einer Spalte des Scroll halb und halb in einer anderen Spalte.

Kannst du mir helfen? DANKE SO VIEL :)

+0

Vergessen Sie lineare Layouts, umarmen Sie relative Layouts !! – ElDuderino

+0

Hölle nein: D !! – MrMee

Antwort

1

Versuchen Sie dies, ich hoffe, das wird Ihnen helfen. Dies ist nur für "Zeigen Sie uns Liebe für Asien" ein Einzelteil.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:orientation="vertical" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="500dp"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="500dp" 
      android:orientation="vertical" 
      android:background="@color/colorAccent"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight=".8" 
       android:background="@color/colorPrimary"> 

      </LinearLayout> 
      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight=".2" 
       android:background="@color/colorAccent"> 

      </LinearLayout> 

     </LinearLayout> 
     <android.support.v4.widget.CircleImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@mipmap/ic_launcher_round" 
      android:layout_gravity="bottom" 
      android:layout_marginBottom="75dp"/> 
    </FrameLayout> 
</LinearLayout> 
+0

Danke, ich werde es später noch einmal versuchen :) – MrMee

+0

Habe es gerade getestet und es zur Arbeit gebracht! Ich musste die android.support.v4 zu einer einfachen Bildansicht ersetzen, aber das hat den Trick! "Können Sie erklären, wie und warum das funktioniert? Danke! – MrMee

+0

Ich fühle mich glücklich, dass Sie Ihre Antwort bekommen. Gemäß Ihrer Anforderung, die Sie benötigen Stellen Sie 'imageview' oder' Circle View' genau zwischen zwei Views ein, also können Sie mit 'FramLayout' die Steuerung überlagern, mit' RelativeLayout' ist es auch möglich, aber 'FramLayout' ist besser zu benutzen https://developer.android.com/reference/android/widget/FrameLayout.html – Shailesh

Verwandte Themen