2013-07-24 2 views
0

У меня есть сетка в календаре в моем приложении. Но мой вид сетки не получает полный вид в разных размерах экрана. Он показывает только половину просмотра страницы, а не полный вид. Так что я Я пытаюсь установить высоту и ширину строки static в моем файле row.xml на основе разных размеров экрана (Mdpi, Hdpi, Xhdpi). Это будет работать нормально в некоторых типах экрана, а не во всех размерах экрана. Так как я могу решить эту проблему ...Сетка Календарь не получает полный вид

Grid Layout:

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

<RelativeLayout 
    android:id="@+id/gridheader" 
    android:layout_width="fill_parent" 
    android:layout_height="40dp" 
    android:background="@drawable/buttonframe" 
    android:orientation="horizontal" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="left" > 

     <TextView 
      android:id="@+id/gridprevious" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:clickable="true" 
      android:drawableLeft="@drawable/calendar_previous" 
      android:gravity="center_horizontal" 
      android:padding="5dp" 
      android:textColor="@color/white" 
      android:textSize="14sp" 
      android:textStyle="bold" /> 
    </LinearLayout> 

    <TextView 
     android:id="@+id/gridtitle" 
     android:layout_width="wrap_content" 
     android:layout_height="40dp" 
     android:layout_centerHorizontal="true" 
     android:gravity="center" 
     android:textColor="#939598" 
     android:textSize="15sp" 
     android:textStyle="bold" /> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@+id/title" 
     android:gravity="right" > 

     <TextView 
      android:id="@+id/gridnext" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:layout_marginRight="10dp" 
      android:clickable="true" 
      android:drawableRight="@drawable/calendar_next" 
      android:gravity="center_horizontal" 
      android:padding="5dp" 
      android:paddingLeft="5dp" 
      android:textColor="@color/white" 
      android:textSize="14sp" 
      android:textStyle="bold" /> 
    </LinearLayout> 
</RelativeLayout> 

<RelativeLayout 
    android:id="@+id/layoutidDays" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="left" > 

     <TextView 
      android:layout_width="0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight=".08" 
      android:background="#666666" 
      android:gravity="center" 
      android:text="@string/sunday" /> 

     <TextView 
      android:layout_width="0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight=".08" 
      android:background="#666666" 
      android:gravity="center" 
      android:text="@string/monday" /> 

     <TextView 
      android:layout_width="0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight=".08" 
      android:background="#666666" 
      android:gravity="center" 
      android:text="@string/tuesday" /> 

     <TextView 
      android:layout_width="0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight=".08" 
      android:background="#666666" 
      android:gravity="center" 
      android:text="@string/wednesday" /> 

     <TextView 
      android:layout_width="0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight=".08" 
      android:background="#666666" 
      android:gravity="center" 
      android:text="@string/thursday" /> 

     <TextView 
      android:layout_width="0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight=".08" 
      android:background="#666666" 
      android:gravity="center" 
      android:text="@string/friday" /> 

     <TextView 
      android:layout_width="0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight=".08" 
      android:background="#666666" 
      android:gravity="center" 
      android:text="@string/saturday" /> 
    </LinearLayout> 
</RelativeLayout> 

<LinearLayout 
    android:id="@+id/gridlayoutid" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#666666" > 

    <GridView 
     android:id="@+id/gridviewid" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:horizontalSpacing="1.5dp" 
     android:stretchMode="columnWidth" 
     android:numColumns="7" 
     android:verticalSpacing="1.5dp" /> 
</LinearLayout> 

Сетка Роу Layout: (row.xml)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="50dp" 
    android:layout_height="65dp"  
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/griddate" 
     android:layout_width="50dp" 
     android:layout_height="27dp" 
     android:layout_gravity="center_horizontal" 
     android:gravity="center" 
     android:textColor="#5C943B" 
     android:textSize="17sp" 
     android:textStyle="bold" > 

    </TextView> 

    <TextView 
     android:id="@+id/gridstatusRemainTask" 
     android:layout_width="50dp" 
     android:layout_height="19dp" 
     android:textColor="#FF0000" 
     android:textStyle="bold" 
     android:layout_gravity="center_horizontal" 
     android:layout_marginRight="2dp" 
     android:gravity="center" 
     android:textSize="15sp" /> 

    <TextView 
     android:id="@+id/gridstatusFinishTask" 
     android:layout_width="50dp" 
     android:layout_height="19dp" 
     android:textColor="#00AEEF" 
     android:textStyle="bold" 
     android:layout_gravity="center_horizontal" 
     android:layout_marginRight="2dp" 
     android:gravity="center" 
     android:textSize="15sp" /> 

</LinearLayout> 

мой взгляд расположение: enter image description here

Я хочу, чтобы вывести следующим образом.

enter image description here

+0

вместо того чтобы изобретать колесо, я хотел бы предложить вам, чтобы захватить и изменить пользовательский интерфейс с [эта библиотека] (https://github.com/roomorama/Caldroid) –

+0

Его трудно понять, просто посмотрев на XML-макет. Но просто проверьте родительский вид, если у него есть какой-либо запас или дополнение для дочернего (GridView), который вы размещаете. –

ответ

0

Вместо использования Linear Layout попробовать Relative Layout:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="90dp" 
    android:layout_height="90dp" 
    android:background="@color/reaction_color_selected"> 
    <TextView 
     android:id="@+id/num_events_per_day" 
     style="@style/calendar_event_style" 
     android:layout_gravity="right" 
     android:text="1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 
    </TextView> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:text="New York" /> 

</RelativeLayout> 
+0

no srikanth его не работает, это может быть использовано только для свертывания только двух предметов ... – Satheesh

+0

hmmm Я пробовал аналогичный макет Satheesh..try с относительной компоновкой для каждой строки –

+0

нет, я пробовал все это, но не получаю решение ... – Satheesh

1

Установите height и width макета вашего GridView.

 android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 

затем установите height и width из вашего GridView в fill_parent а. Надеюсь, это сработает.

Проверьте следующую ссылку и внесите изменения в свой файл Xml. Как код, который вы используете, очень трудно понять. И установите GridView height и width легко.

Android Calendar Sample

+0

спасибо за ваш ответ, но я уже установил ширину и высоту, но не работал – Satheesh

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