現在作業中のプロジェクトで折りたたみツールバーを使用しています。自分のコードから折りたたみツールバーのタイトルを設定していますが、タイトルが大きすぎるとツールバーのメニューアイコンと重なってしまうという問題があります。どうすればこの問題を解決できますか?ツールバータイトルの折りたたみがメニューアイコンと重複しています
私のXMLコード:
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="205dp"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/agent_profile_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginBottom="87dp"
app:expandedTitleMarginStart="130dp"
app:expandedTitleTextAppearance="@style/expandedappbar"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax">
<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="170dp"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="@drawable/back" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="170dp"
android:background="#66000000">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="8dp"
android:layout_marginLeft="130dp"
android:orientation="vertical">
<TextView
android:id="@+id/lbl_agent_profile_position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/lbl_agent_profile_Name"
android:layout_marginBottom="5dp"
android:ellipsize="end"
android:maxLines="1"
android:text="Real Estate Professional at Exit Alliance Realty"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#fff"
android:textSize="12sp"
android:typeface="sans" />
<TextView
android:id="@+id/lbl_agent_profile_ibaaxid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#33ffffff"
android:paddingBottom="1dp"
android:paddingEnd="3dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:paddingStart="3dp"
android:paddingTop="1dp"
android:text="iBaax ID : 123456789"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#fff"
android:textSize="12sp"
android:typeface="sans" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/lnr_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
android:background="#fff"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<ImageView
android:id="@+id/img_agent_profile_image"
android:layout_width="110dp"
android:layout_height="110dp"
android:scaleType="centerCrop"
android:src="@drawable/no_profile" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_below="@+id/backdrop"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_toRightOf="@+id/lnr_img"
android:background="#4d6088"
android:paddingEnd="3dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:paddingStart="3dp"
android:text="Write Review"
android:textAllCaps="false"
android:textSize="12sp" />
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
そして、私の活動のOnCreateイベントメソッドのコードは:
setContentView(R.layout.activity_agent_profile2);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//getSupportActionBar().setTitle("Name");
agent = (Agent) getIntent().getSerializableExtra("Agent");
CollapsingToolbarLayout collapsingToolbar =
(CollapsingToolbarLayout) findViewById(R.id.agent_profile_toolbar);
collapsingToolbar.setTitle(agent.name);
タイトルのTextView –
に一定の幅を与えてみてください動作するようにellipsizeのための私のタイトルにはTextViewにはありません。私はcollapsetoolbar.setTitle( "");で私のコードから直接設定しています。 –