Dans mon application, l'icône se charge dynamiquement et s'adapte automatiquement dans l'emplacement des icônes. Actuellement, l'icône ne redimensionne pas, donc il augmente la hauteur de ActionBar
. J'utilise SupportActionBar
au lieu de ToolBar
parce que je viens de migrer de Activity
vers AppCompatActivity
et que je voulais réutiliser autant que possible. Que peut-on faire pour faire une auto-fit une icône sur le ActionBar
?Android AppCompat SupportActionBar - Comment faire pour que l'icône s'ajuste automatiquement à une certaine taille
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_view_second_screen"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="?wallpaper"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
tools:context="com.sarkms.cclib.SecondScreen" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ListView
android:id="@+id/convView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@android:color/transparent"
android:dividerHeight="10.0sp"
android:transcriptMode="normal"
android:smoothScrollbar="true" >
</ListView>
<TextView
android:id="@+id/lbl_MultiContactsPing_note"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:padding="10dp"
android:background="@drawable/lightblue_rounded_poll_title_bg"
android:visibility="gone"
android:text="@string/lbl_multiplecontacts_ping_note"
android:textSize="20sp"
android:textStyle="italic"
android:textColor="@color/grey_dark" />
</RelativeLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15sp"
android:layout_marginBottom="15sp" >
<ImageView
android:id="@+id/emoticon_btn"
android:layout_width="30sp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:src="@drawable/smiley" />
<ImageView
android:id="@+id/impMsg"
android:layout_width="12dp"
android:layout_height="25dp"
android:layout_gravity="bottom"
android:padding="4dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/imp_msg_unselected_5" />
<ImageView
android:id="@+id/Send"
android:src="@drawable/sendping_7"
android:layout_width="35sp"
android:layout_height="wrap_content"
android:layout_marginLeft="15sp"
android:layout_marginRight="15sp"
android:layout_gravity="bottom" />
</LinearLayout>
Y at-il un problème d'utilisation de 'ToolBar' avec' AppCompatActivity'? –
L'icône est placée au milieu, au lieu de l'aligner à gauche. De plus, je devrai ajouter la barre d'outils à chaque xml de mise en page. Si je pouvais réaliser ce redimensionnement dans SupportActionBar, je pourrais éviter de toucher très layout xml. –
Pouvez-vous poster votre fichier de mise en page, qui comprend l'icône et la barre d'action? –