0

I am trying to include Caldroid calendar in my activity. I want that the calendar ocuppy 3/4 of the screen like this:

enter image description here

But it always shows at the top of the screen.

This is my layout:

<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>

And this is how i attach the caldroid:

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

I search it in StackOverFlow but i dont find the solution.

garciam202
  • 591
  • 2
  • 7
  • 17

2 Answers2

0

Finally i solved it implementing my own custom_cell and modify the padding_bottom to increase the cell size.

<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>

It is one solution but maybe not the most elegant.

garciam202
  • 591
  • 2
  • 7
  • 17
-1

there are two way for this :

first way : use android:layout_weight="" instead static size for LinearLayout

for example :

        <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>

Second Way : using PercentLayout (work with percentage and maybe Clearer)

  1. add Percent library to your app by adding this line to gradle dependency:

     dependencies {
    ...
    compile 'com.android.support:percent:24.1.2' //or any other versions
    ...
    }
    
  2. in 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>
    

notice that :

  • add http://schemas.android.com/apk/res-auto" to first parent of layout
  • android:layout_toRightOf specify the second view(layout_below is possible too)
Saeid
  • 2,261
  • 4
  • 27
  • 59