0

У меня есть макет ScrollView с TableLayout, в котором у меня есть TableRow, который состоит из трех TextViews.scrollview with tablelayout и linearlayouts

Проблема возникает, когда я пытаюсь выровнять TextViews с экраном. TextViews не занимают пространство экрана и вид натирания.

Я приложил код тоже, если вы, ребята, нужно рассмотреть его ...

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_reciept" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.spuck.LayoutTable"> 

    <RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/relativeLayout"> 

     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="49dp" 
      android:src="@drawable/the_one_3" 
      android:id="@+id/the_one" 
      android:layout_alignParentTop="true" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" /> 


    </RelativeLayout> 
    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="300dp" 
     android:id="@+id/scrollView2" 
     android:layout_below="@+id/relativeLayout" 
     android:layout_above="@+id/addButton"> 


      <TableLayout 
       android:id="@+id/maintable" 
       android:layout_width="match_parent" 
       android:layout_height="300dp"> 

       <TableRow 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/tableRow1"> 

        <LinearLayout android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:orientation="horizontal" 
         android:id="@+id/linear_layout_two_table_layout"> 


         <TextView 
          android:layout_width="0dp" 
          android:layout_height="wrap_content" 
          android:text="Date" 
          android:textAlignment="center" 
          android:textSize="20dp" 
          android:layout_weight="0.5" 
          android:background="@drawable/cell_shape" 
          /> 

         <TextView 
          android:layout_width="0dp" 
          android:layout_height="wrap_content" 
          android:text="Session Time" 
          android:textSize="20dp" 
          android:layout_weight="1" 
          android:background="@drawable/cell_shape" 
          /> 

         <TextView 
          android:layout_width="0dp" 
          android:layout_height="wrap_content" 
          android:text="Average Speed" 
          android:layout_gravity="center" 
          android:textSize="20dp" 
          android:layout_weight="1" 
          android:background="@drawable/cell_shape" 
          /> 

        </LinearLayout> 
       </TableRow> 
      </TableLayout> 

    </ScrollView> 


    <Button 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/addButton" 
     android:text="Scan item barcode" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 

</RelativeLayout> 

ответ

0

Набор в LinearLayout android:layout_weight="2.5", который является суммой веса макета LinearLayout детей. После этого макет должен быть выровнен влево и вправо.

<LinearLayout android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:layout_weight="2.5" 
    android:id="@+id/linear_layout_two_table_layout"> 
+0

Я попробую это точно, теперь у меня есть тон в другой проблеме, я добавил навигационное меню и нижнюю панель навигации в этом же макете в конце, и теперь его не показывает мне таблицу. Есть идеи? –

+0

Извините, без исходного кода, довольно сложно сказать, где проблема. Я попытался реализовать нижнюю панель навигации на основе этого учебника https://medium.com/@hitherejoe/exploring-the-android-design-support-library-bottom-navigation-drawer-548de699e8e0#.4bvk8trr4 для меня в любом случае: https://postimg.org/image/n1gjcalm7/ Не добавлял навигационное меню, но он не должен нарушать таблицу. Если у вас все еще есть проблемы с этим, я думаю, вы должны опубликовать новый вопрос. – Sabriael

+0

позволяет общаться в чате, я новичок в StackOverflow, поэтому, пожалуйста, сообщите мне сначала, если вы можете –