TP SINGH
TP SINGH

Reputation: 31

add two value in one attribute in android

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent+?actionBarSize">

you can see 3rd line of code how to add this two value and get the height with adding two vale "android:layout_height="match_parent+?actionBarSize" in the our program in android studio in java.

Upvotes: 1

Views: 76

Answers (1)

ankor ank
ankor ank

Reputation: 302

Your query is not clear.

You can't do it in XML

android:layout_height="match_parent+?actionBarSize"

However if you want to hide ActionBar from the entire App, you can use

1. styles.xml

<resources>
    <!---Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
 
        <!---Customize your theme here.-->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>
</resources>

2. Hide ActionBar from any particular activity using Java code

public class MainActivity extends AppCompatActivity {
 
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        // Take instance of Action Bar
        // using getSupportActionBar and
        // if it is not Null
        // then call hide function
        if (getSupportActionBar() != null) {
            getSupportActionBar().hide();
        }
    }
}

3. Hide ActionBar while user interaction using WindowManager

public class MainActivity extends AppCompatActivity {
 
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
 
        // set Windows Flags to Full Screen
        // using setFlags function
        getWindow().setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_main);
    }
}

4. Hide ActionBar from any particular activity using try-catch

public class MainActivity extends AppCompatActivity {
 
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        // try block to hide Action bar
        try {
            this.getSupportActionBar().hide();
        }
        // catch block to handle NullPointerException
        catch (NullPointerException e) {
        }
    }
}

Upvotes: 2

Related Questions