MaterialCalendarView not occupying full width android - android

I am placing a Material calendar view and i want the calendar height to occupy half of the screen and it was made by using layout weight but the calendar not occupying the full width.
one more problem is that I want to increase the text size of the date please refer me any idea
The XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="symphony.acube.com.symphony.activity.patient.acitivity.mySchedule.MyScheduleActivity">
<include layout="#layout/toolbar_layout"></include>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/llCalendarContainer"
android:orientation="vertical"
android:layout_weight="1">
<com.prolificinteractive.materialcalendarview.MaterialCalendarView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/calendarView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:mcv_showOtherDates="all"
app:mcv_selectionColor="#color/toolbar_red"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
</LinearLayout>
</LinearLayout>
</LinearLayout>
The following is the actual window i am getting currently
In the above calendar should occupy full width and also the text size of the date must be some big
Thankyou in advance

To stretch the width of the calendar should:
The measureTileSize reduce by a factor of (in the method onMeasure class MaterialCalendarView)
int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec ((int) (p.height * (measureTileSize / 1.5)), MeasureSpec.EXACTLY);
The same is done in the MonthView
int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec ((int) (measureTileSize / 1.5), MeasureSpec.EXACTLY);
Something come up with the background (stretched into an oval)
For more follow this issue

Related

Getting padding in fullscreen camera view (FrameLayout)

I have this layout:
`
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:padding="0dp"
android:background="#android:color/transparent"
android:id="#+id/parent_view"
>
<FrameLayout
android:id="#+id/camera_preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<Button
android:id="#+id/button_capture"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:text="Capture" />
</FrameLayout>
</LinearLayout>
`
I am getting black padding in camera view like this, on the right side, notice the vertical black space/strip on right:
Don't mind the capture button in middle of screen, I'll position it later. But the question I have is, how to remove the unwanted padding and make FramLayout full screen?
CameraSourcePreview doesn't fill whole screen height that bug fixed by
Comment or remove below lines from CameraSourcePreview.java
if (childHeight > layoutHeight) {
childHeight = layoutHeight;
childWidth = (int)(((float) layoutHeight / (float) height) * width);
}

Fill vertical space between two views (+scroll)

I have 3 views.
1. View A has a fixed height and aligned to the top of the screen.
2. View B has a fixed height and aligned to the bottom of the screen.
3. View C has to fill a vertical space between views A and B but has to be minimum X height. If the vertical space between A and B is less than Xdp, the vertical scroll bar has to appear (and view B has to scroll, not to be sticked to bottom).
What I have so far (a bit simplified), it may be completely wrong:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/layout_banner_top"
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_height="#dimen/statistics_probanner_height">
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" <!-- UPD here as McAdam331 suggested -->
android:minHeight="#dimen/statistics_circular_progress_container_height"
android:layout_below="#+id/layout_banner_top"
android:layout_above="#+id/layout_banner_bottom">
<!-- here is some content -->
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/statistics_bottom_bar_height"
android:id="#+id/layout_banner_bottom"
android:layout_alignParentBottom="true">
</RelativeLayout>
</RelativeLayout>
</ScrollView>
How it looks:
Picture 1
Picture 2
Currently minHeight of the view in between (view C) is set to 600dp, but as you see on Picture 2 view C is filling an available space between top and bottom views, height is too small and scroll not appearing.
Is it possible to implement? How can I achieve that behaviour?
The issue is that you've set both height and minheight to the same value:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/statistics_circular_progress_container_height"
android:minHeight="#dimen/statistics_circular_progress_container_height"
android:layout_below="#+id/layout_banner_top"
android:layout_above="#+id/layout_banner_bottom">
In other words, the view won't exceed the hight you've given it already. What I would do is set the layout_height to wrap_content, and keep the min_height attribute as it is.
this way, if the space is larger than the dimension given, it wil just bind above and below the banners. Otherwise, it will hold that minimum value.
Resolved.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/statistics_probanner_height"
android:gravity="top">
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:minHeight="#dimen/statistics_circular_progress_container_height">
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/statistics_bottom_bar_height"
android:layout_gravity="bottom">
</LinearLayout>
</LinearLayout>
</ScrollView>

full screen layout in Scroll View

I want to have 2 layouts inside ScrollView. First layout should be on the full screen and second layout below first one. When activity starts it is not possible see second layout. Second layout is possible see after scroll screen. Please take a look on my image for better understand.
Layout code: `
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="15dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/layout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="#+id/layout2"
android:layout_width="match_parent"
android:layout_height="200dp"
android:orientation="vertical" >
<!-- this layout can be any height you want -->
</LinearLayout>
</LinearLayout>
</ScrollView>`
Get the device screen height:
Point size = new Point();
getWindowManager().getDefaultDisplay().getSize(size);
int screenHeight = size.y;
Find the LinearLayout:
LinearLayout layout = (LinearLayout)findViewById(R.id.layout1);
Set the height of the layout based on the screen height you got earlier:
LayoutParams params = layout.getLayoutParams();
params.height = screenHeight - getStatusBarHeight();
Done. Be sure to call all of those methods in your onCreate method.
Hope this helps!

How to split the screen dynamically in android without xml

I have tried to split the screen using xml..here is the code
Please try this xml..I need the same layout programatically.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="318dp"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:background="#android:color/holo_purple">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="318dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" android:background="#android:color/holo_purple">
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="318dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:background="#android:color/holo_blue_dark">
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="318dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:background="#android:color/darker_gray">
</LinearLayout>
</LinearLayout>
</LinearLayout>
But, I need to do programatically to split the screen. Can anyone provide me the solution?
By splitting the screen you mean dividing layouts width then you can try as below..
// gets the screen width
float screenWidth = getWindowManager()
.getDefaultDisplay().getWidth();
You will get screen width from above code..
and for screen height
// gets the screen height
float screenHeight = getWindowManager()
.getDefaultDisplay().getHeight();
then all you have to do is set the layout width using LayoutParams.
LinearLayout view = (LinearLayout) findViewById(R.id.ur_layout_id);
view.setLayoutParams(new LinearLayout.LayoutParams((int) screenWidth / 3,
(int) screenHeight , 1f));
you can set layoutwidth to divide screen in half by screenWidth / 2, in 3 parts by screenWidth / 3 and so on..
Hope this helps..

How can I set an Android text box to only take up 60% of the overall width in XML?

I want to set up a text box, but I want it on multiple devices and to only take up 70% of the room on the screen. Can I do this?
hi try this way in xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:weightSum="10"
android:id="#+id/commonlayout" >
<TextView android:id="#+id/tvlogin"
android:layout_height="fill_parent"
android:text="My Text View in 60%"
android:layout_width="0dp"
android:layout_weight="6">
</TextView>
</LinearLayout>
use android:padding = "yourvaluespx";
PX is the value at yourvalues insert any number
Add a empty LinearLayout beside it, set both Layout Width to 0dp. Then set the weight of TextView (or EditText) and the LinearLayout to 0.7 and 0.3 respectively
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:layout_height="match_parent" android:id="#+id/linearLayout1" android:layout_weight="0.3" android:layout_width="0dp"></LinearLayout>
<TextView android:text="TextView" android:id="#+id/textView1" android:layout_height="wrap_content" android:layout_weight="0.7" android:layout_width="0dp"></TextView>
</LinearLayout>
please try this::
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
int int_var = (width * 60)/100;
and put int_var as width

Categories

Resources