1

Some attributes are defined in xml with sort of a question mark as given below for the layout_height of the toolbar:

<androidx.appcompat.widget.Toolbar
        android:id="@+id/app_toolbar"
        android:layout_width="0dp"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/colorPrimary"
        android:textSize="@dimen/actionBarTextSize"
        app:titleTextColor="#929292"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">
</androidx.appcompat.widget.Toolbar>  

How do you get these values in java? Say I instantiated the toolbar in java and want to set the height and use the actionBarSize defined by the variable in the xml above, how do I do that?

juztcode
  • 1,196
  • 2
  • 21
  • 46
  • 1
    Here you go: https://stackoverflow.com/questions/7896615/android-how-to-get-value-of-an-attribute-in-code. Those attributes with a `?` are called attributes, or references. – Nicolas Feb 14 '20 at 15:37

0 Answers0