I am editing Sipdroid and making changes to the UI, but every single activity in this application has a huge chin on top which I can't seem to hide in any way. It looks like it's recognized as the status bar, as you can see from the code that I've shared below, but also by the fact that whenever I change the status bar color, the chin turns to that color as well. As of now, the only way I've found for it to not create padding on top of the screen is to add <item name="android:windowTranslucentStatus">true</item>
to the style XML.
The following is the code for both the layout XML file and the Kotlin class:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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">
<TextView
android:id="@ id/hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Hello World"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
package org.sipdroid.sipua.ui
import android.app.Activity
import android.graphics.Rect
import android.os.Bundle
import android.view.View
import android.view.Window
import android.widget.TextView
import android.widget.Toast
import org.sipdroid.sipua.R
class TestActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_test)
val btn = findViewById<TextView>(R.id.hello)
btn.setOnClickListener {
// gets the status bar height
val rectangle = Rect()
window.decorView.getWindowVisibleDisplayFrame(rectangle)
val statusBarHeight = rectangle.top
val contentViewTop = window.findViewById<View>(Window.ID_ANDROID_CONTENT).top
val titleBarHeight = contentViewTop - statusBarHeight
// makes the TextView as high as the status bar,
// so we have a visual representation of the
// actual height with layout bounds visible
btn.height = statusBarHeight
Toast.makeText(
this@TestActivity,
"$statusBarHeight $titleBarHeight ${rectangle.height()}",
Toast.LENGTH_SHORT
).show()
}
}
}
These are screenshots both with and without layout bounds shown.
CodePudding user response:
Ok so I got this solved messing around with stuff and turned out the only thing I needed to do was to remove the following piece of code from the Manifest:
<supports-screens
android:anyDensity="false"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
CodePudding user response:
Add getActionBar().hide()
in the onCreate method before setContentView()