2016-12-26 2 views
0

Я пытаюсь включить календарь Caldroid в свою деятельность. Я хочу, чтобы календарь ocuppy 3/4 экрана, как это:Caldroid: Как изменить размер и положение

enter image description here

Но он всегда показывает в верхней части экрана.

Это мой макет:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:id="@+id/opciones" 
     android:layout_width="299dp" 
     android:layout_height="match_parent" 
     android:orientation="horizontal"> 
    </LinearLayout> 

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

</LinearLayout> 

И это, как я прикрепить caldroid:

FragmentTransaction t = getSupportFragmentManager().beginTransaction(); 
     t.replace(R.id.calendar1, caldroidFragment); 
     t.commit(); 

я ищу его в StackOverflow, но я не нашел решение.

ответ

0

Наконец я решил, что осуществление моей custom_cell и изменить padding_bottom, чтобы увеличить размер ячейки.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/custom_cell" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" 
    android:orientation="vertical" 
    android:padding="10dp" > 

    <TextView 
     android:id="@+id/tv1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingBottom="68dp"/> 

</LinearLayout> 

Это одно решение, но, возможно, не самое элегантное.

0

есть два пути для этого:

первый способ: использование android:layout_weight="" вместо статического размера для LinearLayout

, например:

 <LinearLayout 
      android:id="@+id/parentLinearLayout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <LinearLayout 
       android:id="@+id/options" 
       android:layout_width="0dp" 
       android:layout_weight="0.3" 
       android:layout_height="match_parent" 
       android:orientation="horizontal"> 
      </LinearLayout> 

      <LinearLayout 
       android:id="@+id/calendar1" 
       android:layout_width="0dp" 
       android:layout_weight="0.7" 
       android:layout_height="match_parent" 
       android:orientation="horizontal"> 
      </LinearLayout> 

     </LinearLayout> 

Второй способ: с помощью PercentLayout (работы с процентом и, возможно, Clearer)

  1. добавить Percent библиотеки для вашего приложения, добавив следующую строку в Gradle зависимости:

    dependencies { 
    ... 
    compile 'com.android.support:percent:24.1.2' //or any other versions 
    ... 
    } 
    
  2. в XML layout:

    <LinearLayout 
         android:id="@+id/options" 
         android:layout_width="0dp" 
         app:layout_widthPercent="30%" 
         android:layout_height="match_parent" 
         android:orientation="horizontal"> 
        </LinearLayout> 
    
        <LinearLayout 
         android:layout_toRightOf="@id/options" 
         android:id="@+id/calendar1" 
         android:layout_width="0dp" 
         app:layout_widthPercent="70%" 
         android:layout_height="match_parent" 
         android:orientation="horizontal"> 
    </LinearLayout> 
    

обратите внимание, что:

  • добавить http://schemas.android.com/apk/res-auto" к первому родителю макете
  • android:layout_toRightOf указать вторую точку зрения (layout_below возможно тоже)
+0

это не работает для меня. калдоид держит его размер. это только изменяет его ширину, но не его высоту. – garciam202

+0

@ garciam202 для высоты вы должны использовать 'app: layout_heightPercent =" int% "' – Saeid

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