Skip to content

Commit

Permalink
smooth scroll textviews
Browse files Browse the repository at this point in the history
  • Loading branch information
eycorsican committed Feb 25, 2019
1 parent f6ba086 commit 27a4a45
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.view.Menu
import android.view.MenuItem
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_logcat.*
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
Expand All @@ -29,7 +30,7 @@ class LogcatActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_logcat)
logcatTextView = findViewById<TextView>(R.id.logcat_text)
logcatTextView.movementMethod = ScrollingMovementMethod()
logcatScroll.isSmoothScrollingEnabled = true

bgThread = object : Thread() {
override fun run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.content_main.*
import org.json.JSONException
import org.json.JSONObject
import android.view.MotionEvent
import android.view.View.OnTouchListener
import android.view.View




class MainActivity : AppCompatActivity() {
Expand Down Expand Up @@ -113,6 +118,8 @@ class MainActivity : AppCompatActivity() {

updateUI()

configScroll.isSmoothScrollingEnabled = true

fab.setOnClickListener { view ->
if (!running && !starting) {
starting = true
Expand Down
26 changes: 19 additions & 7 deletions app/src/main/res/layout/activity_logcat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@
android:layout_height="match_parent"
android:isScrollContainer="true">

<TextView
android:id="@+id/logcat_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:scrollbars="vertical"
android:text="TextView" />
<ScrollView
android:id="@+id/logcatScroll"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/logcat_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:scrollbars="vertical"
android:text="TextView" />
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
33 changes: 23 additions & 10 deletions app/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,28 @@
tools:context="fun.kitsunebi.kitsunebi4android.ui.MainActivity"
tools:showIn="@layout/activity_main">

<EditText
android:id="@+id/configView"
<ScrollView
android:id="@+id/configScroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<EditText
android:id="@+id/configView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
</LinearLayout>
</ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 27a4a45

Please sign in to comment.