我可以知道如何CalendarView在Android中调整大小吗?该CalendarView比屏幕占据一半以上.我希望它变得更小,可能是屏幕的40%.谢谢.
智能手机中的默认CalendarView大小占据了一半以上
我目前的XML:
<RelativeLayout 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.ada.landing.MainActivity">
<CalendarView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/calendarView"
android:firstDayOfWeek="2"/></RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我尝试了另一种方式来定义CalendarView,但整体高度降低但不会按比例收缩:
<CalendarView
android:layout_width="500dp"
android:layout_height="200dp"
android:id="@+id/calendarView"
android:firstDayOfWeek="2" />
Run Code Online (Sandbox Code Playgroud) 我的屏幕上有7个日期标签.但是,如果日期是另一个月,我不允许用户单击该选项卡.我想让它们可见但不可点击.
这是我的代码的一部分:
public void setupViewPager(ViewPager viewPager, ArrayList<String> id, ArrayList<String> tasks,
ArrayList<Double> mondayHours, ArrayList<Double> tuesdayHours,
ArrayList<Double> wednesdayHours, ArrayList<Double> thursdayHours,
ArrayList<Double> fridayHours, ArrayList<Double> saturdayHours,
ArrayList<Double> sundayHours) {
Bundle bundle = new Bundle();
bundle.putStringArrayList(EXTRA_CHECKED_TASK_ID, id);
bundle.putStringArrayList(EXTRA_CHECKED_TASKS, tasks);
bundle.putSerializable(EXTRA_MONDAY, mondayHours);
bundle.putSerializable(EXTRA_TUESDAY, tuesdayHours);
bundle.putSerializable(EXTRA_WEDNESDAY, wednesdayHours);
bundle.putSerializable(EXTRA_THURSDAY, thursdayHours);
bundle.putSerializable(EXTRA_FRIDAY, fridayHours);
bundle.putSerializable(EXTRA_SATURDAY, saturdayHours);
bundle.putSerializable(EXTRA_SUNDAY, sundayHours);
final String MON = "MON" + "\n" + MainActivity.sevenDatesList.get(0);
final String TUE = "TUE" + "\n" + MainActivity.sevenDatesList.get(1);
final String WED = "WED" + "\n" + MainActivity.sevenDatesList.get(2);
final String THU = "THU" …Run Code Online (Sandbox Code Playgroud) 我的屏幕上有7个日期标签,选中标签后,文字为黑色; 而其他可选标签的颜色为白色.如果日期是另一个月,我希望文本颜色为灰色.
我假设第一个选项卡是0,第二个选项卡是1,并一直持续到6.如图所示,我想更改选项卡(3),选项卡(4),选项卡(5)和选项卡(6)的文本颜色.当它满足所需条件(而不是xml)时,如何以编程方式完成,将这4个选项卡中的文本颜色设置为灰色?
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin">
<TextView
android:id="@+id/lblWeekMsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/week"
android:textAppearance="?attr/textAppearanceListItem" />
<TextView
android:id="@+id/lblWeekNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/lblWeekMsg"
android:layout_alignBaseline="@id/lblWeekMsg"
android:text=""
android:textAppearance="?attr/textAppearanceListItem" />
</RelativeLayout>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="30">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/app_bar_layout">
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabTextColor="@android:color/white"
app:tabMode="scrollable"
app:tabGravity="fill" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
我用这种方式用片段创建标签
public void setupViewPager(ViewPager viewPager, ArrayList<String> id, ArrayList<String> tasks,
ArrayList<Double> mondayHours, ArrayList<Double> tuesdayHours,
ArrayList<Double> wednesdayHours, ArrayList<Double> thursdayHours,
ArrayList<Double> fridayHours, ArrayList<Double> saturdayHours,
ArrayList<Double> sundayHours) {
Bundle …Run Code Online (Sandbox Code Playgroud)