我目前遇到了折叠工具栏布局标题的问题。目前,即使android:ellipsize="end"
并且android:fitsSystemWindows
尚未使用,我的自动也会被截断。我有很多很长的标题,但我无法完全显示标题与android截断它们与“...”屏幕截图:
Truncated Image
如果有人能帮我解决这个问题,我将不胜感激。我不确定是否有办法让标题双行而不是单行是否会有所帮助 干杯
ly_13_tachycardiapalpitations.xml:
tools:context=".HomeActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/ly_13_tachycardiapalpitations.appbar"
android:layout_width="match_parent"
android:layout_height="300dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/ly_13_tachycardiapalpitations.collapsing"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="0dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/ly_13_tachycardiapalpitations.imageview.placeholder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="@drawable/ly_11_lowurineoutputcatheterisedpatient_picture2"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<!--layout of pin mode is the one just above-->
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
app:behavior_overlapTop="5dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:cardElevation="8dp"
app:contentPadding="16dp"
android:id="@+id/Cardview1"
>
<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=".klass11LowUrineOutputCatheterisedPatient">
<!--Title-->
<!--Initial Assessment-->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Initial Assessment"
android:textSize="22dp"
android:padding="8dp"
android:textStyle="bold"
android:fontFamily="sans-serif-light"
android:gravity="left"
android:id="@+id/ly_11_lowurineoutputcatheterisedpatient_initial_assessment_title" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dp"
android:padding="8dp"
android:layout_below="@id/ly_11_lowurineoutputcatheterisedpatient_initial_assessment_title"
android:id="@+id/ly_11_lowurineoutputcatheterisedpatient_initial_assessment_body" />
<!--Examination-->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Examination"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:layout_below="@id/ly_11_lowurineoutputcatheterisedpatient_initial_assessment_body"
android:id="@+id/ly_11_lowurineoutputcatheterisedpatient_examination_title2" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/ly_11_lowurineoutputcatheterisedpatient_initial_assessment_title"
android:background="#ddd" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/ly_11_lowurineoutputcatheterisedpatient_examination_title2"
android:id="@+id/ly_11_lowurineoutputcatheterisedpatient_examination_body2" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:cardElevation="8dp"
app:contentPadding="16dp"
android:id="@+id/Cardview2"
android:layout_below="@+id/Cardview1"
>
<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=".klass11LowUrineOutputCatheterisedPatient">
<!--Title-->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="ATSP Re: Decreased GCS2"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:textStyle="bold"
android:id="@+id/ly_11_lowurineoutputcatheterisedpatient_topic_title2" />
<!--Initial Assessment-->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Initial Assessment"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:layout_below="@id/ly_11_lowurineoutputcatheterisedpatient_topic_title2"
android:id="@+id/ly_11_lowurineoutputcatheterisedpatient_initial_assessment_title2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/ly_11_lowurineoutputcatheterisedpatient_initial_assessment_title2"
android:id="@+id/ly_11_lowurineoutputcatheterisedpatient_initial_assessment_body2" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
<!--<android.support.design.widget.FloatingActionButton-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="bottom|end"-->
<!--android:layout_marginBottom="@dimen/activity_vertical_margin"-->
<!--android:layout_marginEnd="@dimen/activity_horizontal_margin"-->
<!--android:layout_marginRight="@dimen/activity_horizontal_margin"-->
<!--android:src="@mipmap/ic_launcher">-->
<!--</android.support.design.widget.FloatingActionButton>-->
活动:klass13Tachycardiapalpitations.java
package com.heemobileapp.atsp;
public class klass13Tachycardiapalpitations extends AppCompatActivity {
private CoordinatorLayout coordinatorLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ly_13_tachycardiapalpitations);
coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinator);
CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.ly_13_tachycardiapalpitations_collapsing);
collapsingToolbar.setTitle("Tachycardia/Palpitations");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_home, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_settings:
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
答案 0 :(得分:0)
希望它会帮助你。以下是textview的标题
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="300dp"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginBottom="160dp"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/quila2"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/abc_text_size_subhead_material"
android:textColor="@android:color/white"
android:layout_marginBottom="32dp"
android:layout_marginEnd="64dp"
android:layout_marginStart="48dp"
app:layout_collapseMode="parallax"
android:text="Tachycardia/Palpitations"/>
<android.support.v7.widget.Toolbar
android:id="@+id/anim_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/abc_text_size_subhead_material"
android:textColor="@android:color/white"
android:layout_marginBottom="32dp"
android:layout_marginEnd="64dp"
android:layout_marginStart="48dp"
app:layout_collapseMode="parallax"
android:text="Tachycardia/Palpitations"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
答案 1 :(得分:0)
添加您的:android.support.design.widget.CollapsingToolbarLayout
app:expandedTitleTextAppearance="@style/HeaderTitleStyle"
在您的 Styles.xml
上创建 <style name="HeaderTitleStyle" parent="@android:style/TextAppearance">
<item name="android:textColor">#FFFFFF</item>
<item name="android:textSize">20sp</item>
<item name="android:singleLine">false</item>
</style>