2017-02-10 2 views
-1

Мои вопросы:Как выровнять значки и отображать тексты как шатер во вложенных линейных и относительных макетах?

  1. Как я могу выровнять расположение, как показано ниже

  2. Как я Получать текст в TextView с анимацией аналогичной из шатра текста (вместо Welcome Back, Джон Doe), которое прокручивается справа налево

Цель

enter image description here

, но я не могу выровнять иконки здесь, и это то, что я получаю: Screenshot_2

enter image description here

Концепция:

Эти иконки и будет отображать номера в красном круге всякий раз, когда появляется уведомление или сообщение получено.

С правой стороны я хочу отобразить текст, который зависит от текста, полученного как сообщение или текст в виде уведомления. Включите его динамическое, которое постоянно меняется.

Я застрял на этой части и не смог ее решить. Я буду благодарен, если кто-нибудь сможет мне помочь! Благодаря

<?xml version="1.0" encoding="utf-8"?> 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:id="@+id/activity_landing_page" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="16dp" 
     android:paddingRight="16dp" 
    tools:context="com.thebitshoes.uocn.AdminHome" 
     android:orientation="vertical" 
     android:weightSum="2" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="0.66" 
     android:orientation="vertical" 
     android:weightSum="1"> 
     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:src="@mipmap/admin_bg_pic" 
      android:layout_gravity="center_horizontal" 
      android:layout_weight="1.22" /> 
     </LinearLayout> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:weightSum="1" 
     android:background="#737D8C"> 

     <RelativeLayout 
      android:layout_width="0dp" 
      android:layout_height="40dp" 
      android:background="#3c424c" 
      android:layout_weight="0.31"> 

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@mipmap/message_icon_new" 
       android:id="@+id/message_icon" 
       android:layout_centerVertical="true" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentStart="true" 
       android:layout_marginLeft="18dp" 
       android:layout_marginStart="18dp" /> 

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@mipmap/notification_icon" 
       android:id="@+id/notification_icon" 
       android:layout_alignParentRight="true" 
       android:layout_alignParentEnd="true" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Welcome Back, John Doe !" 
       android:textColor="#ffffff" 

       android:textSize="18sp" 
       /> 
     </RelativeLayout> 



    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1.34" 
     > 


    </LinearLayout> 



</LinearLayout> 
+0

не знаю, почему он получил downvoted :( – ThePercept

ответ

2
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/activity_landing_page" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:weightSum="2"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="0.66" 
     android:orientation="vertical" 
     android:weightSum="1"> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal" 
      android:layout_weight="1.22" 
      android:src="@mipmap/ic_launcher" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="#737D8C" 
     android:orientation="horizontal"> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="40" 
      android:background="#3c424c" 
      android:orientation="horizontal"> 

      <ImageView 
       android:id="@+id/message_icon" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:layout_weight="1" 
       android:src="@drawable/add_event" /> 

      <ImageView 
       android:id="@+id/notification_icon" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:layout_weight="1" 
       android:src="@drawable/add_notice" /> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="60" 
      android:background="#3c424c" 
      android:orientation="horizontal"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:padding="5dp" 
       android:text="Welcome Back, John Doe !" 
       android:textColor="#ffffff" 
       android:textSize="18sp" /> 
     </LinearLayout> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1.34" /> 
</LinearLayout> 
+0

Спасибо Маитри, ваше предложение помогло :) !! – ThePercept

0

Для шатровым кода вы можете посмотреть на Marquee text in Android

и я не уверен, но если вы сделаете свой TextView ширина матча родителя должно быть в порядке, но я не уверен на 100%.

+0

Спасибо за Marquee ресурс !! искал это. – ThePercept

 Смежные вопросы

  • Нет связанных вопросов^_^