1

Im using Caldroid library. I want to use it inside my layout. My layout also includes textview. But when I use Caldroid with framelayout the other views disappear.

Here is XML and Java codes using Caldroid with FrameLayout.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:tools="http://schemas.android.com/tools"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         tools:context="com.birfincankafein.mpandroidchart.CalendarFragment"
          android:orientation="vertical">

<!-- TODO: Update blank fragment layout -->

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:id="@+id/container_caldroid"
    android:layout_weight="0.4">
</FrameLayout>

<ImageView
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:id="@+id/imageView_divider"
    android:layout_below="@+id/container_caldroid"
    android:focusableInTouchMode="false"
    android:layout_marginTop="2dp"
    android:layout_marginBottom="2dp"
    android:layout_weight="0.1"/>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/imageView_divider"
    android:background="#ffff00ba"
    android:layout_weight="0.4">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Text"
        android:id="@+id/textView_description"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:background="#ff00ebff"/>
</RelativeLayout>

Here is java code:

mCaldroidFragment = new CaldroidFragment();
    Bundle args = new Bundle();
    args.putInt( CaldroidFragment.START_DAY_OF_WEEK, CaldroidFragment.MONDAY );
    mCaldroidFragment.setArguments( args );
    getActivity().getSupportFragmentManager().beginTransaction().replace( R.id.container_calendar , mCaldroidFragment ).commit();

And here what it looks like: Caldroid

These are codes for using Caldroid with fragment.

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:tools="http://schemas.android.com/tools"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         tools:context="com.birfincankafein.mpandroidchart.CalendarFragment"
          android:orientation="vertical">

<!-- TODO: Update blank fragment layout -->

<fragment
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    class="com.roomorama.caldroid.CaldroidFragment"
    android:id="@+id/container_caldroid"
    android:layout_weight="0.4">
</fragment>

<ImageView
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:id="@+id/imageView_divider"
    android:layout_below="@+id/container_caldroid"
    android:focusableInTouchMode="false"
    android:layout_marginTop="2dp"
    android:layout_marginBottom="2dp"
    android:layout_weight="0.1"/>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/imageView_divider"
    android:background="#ffff00ba"
    android:layout_weight="0.4">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Text"
        android:id="@+id/textView_description"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:background="#ff00ebff"/>
</RelativeLayout>

And there is no need to java code. It had been initialized. Here is how it looks: Caldroid

Why this happens? I want to use this library inside the frame layout. Because I have to initialize it manually. I have to set something neccassary.

Ps: The background color is for detect where the layout is.

Dmitry
  • 14,306
  • 23
  • 105
  • 189
Metehan Toksoy
  • 1,885
  • 3
  • 22
  • 39

1 Answers1

0

I'm not able to recreate the same. The below code works fine for me.

XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:id="@+id/cal_container"
    android:layout_weight="0.4"/>

<ImageView
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:id="@+id/imageView_divider"
    android:layout_below="@+id/container_caldroid"
    android:focusableInTouchMode="false"
    android:layout_marginTop="2dp"
    android:layout_marginBottom="2dp"
    android:layout_weight="0.1"/>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/imageView_divider"
    android:background="#ffff00ba"
    android:layout_weight="0.4">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Text"
        android:id="@+id/textView_description"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:background="#ff00ebff"/>
</RelativeLayout>
</LinearLayout>

Fragment:

    public class meets extends Fragment {

    public meets() {
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View root = inflater.inflate(R.layout.fragment_meets, container, false);

        CaldroidFragment mCaldroidFragment = new CaldroidFragment();
        Bundle args = new Bundle();
        args.putInt( CaldroidFragment.START_DAY_OF_WEEK, CaldroidFragment.MONDAY );
        mCaldroidFragment.setArguments( args );
        getActivity().getSupportFragmentManager().beginTransaction().replace( R.id.cal_container , mCaldroidFragment ).commit();

        return root;
    }
}

enter image description here

Abhilash Kishore
  • 2,063
  • 2
  • 15
  • 31