Skip to content

Commit a869aec

Browse files
1951FDGhannesa2
authored andcommitted
Bugfix: RecyclerView UI: Set minimum width equal to parent (we have dynamic width (wrapping contents of variable widths) and if log entries are short or if you change device orientation to landscape, our width may be smaller than parent)
1 parent 3c4c21c commit a869aec

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

LogcatCoreLib/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ android {
1616
}
1717

1818
dependencies {
19+
implementation "androidx.core:core-ktx:1.3.2"
1920
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
2021
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3"
2122
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1"

LogcatCoreLib/src/main/java/info/hannes/logcat/base/LogBaseFragment.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import android.view.*
1212
import android.widget.CompoundButton
1313
import androidx.appcompat.widget.SearchView
1414
import androidx.core.content.FileProvider
15+
import androidx.core.view.doOnLayout
1516
import androidx.fragment.app.Fragment
1617
import androidx.lifecycle.coroutineScope
1718
import androidx.recyclerview.widget.LinearLayoutManager
@@ -50,6 +51,11 @@ abstract class LogBaseFragment : Fragment() {
5051
it.layoutManager = LinearLayoutManager(it.context)
5152
it.recycledViewPool.setMaxRecycledViews(R.layout.item_log, DEFAULT_MAX_SCRAP)
5253
}
54+
55+
logsRecycler.doOnLayout {
56+
it.minimumWidth = (it.parent as ViewGroup).width
57+
}
58+
5359
// empty adapter to avoid "E/RecyclerView﹕ No adapter attached; skipping layou..."
5460
logListAdapter = LogListAdapter(mutableListOf(), currentFilter).also {
5561
it.stateRestorationPolicy = RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY

0 commit comments

Comments
 (0)