我想用 kotlin 读取字符串中的 html 站点。
但我找不到如何从网站获取信息或需要哪个命令。
如何在代码中创建一个动态添加 TextViews 的 ScrollView?现在我有:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp"
>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Create TextView"
/>
<ScrollView
android:id="@+id/Scroll"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
作为布局文件,这是我的 kotlin 文件:
class Abfahrtsmonitor : AppCompatActivity(){
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.abfahrtsmonitor)
// Variable for counting text view
var counter: Int = 1;
// Set a click listener for button widget
button.setOnClickListener{
// Create a new TextView instance programmatically
val text_view: TextView = TextView(this)
// …
Run Code Online (Sandbox Code Playgroud) 我有一个 editText 视图、一个 RecyclerView 和一个底部导航视图。当我提示 EditText 时,键盘会打开并且 RecyclerView 被填充。但是BottomNavigationview 仍然在现在打开的键盘之上,而我的Recyclerview 在bottomnavigation 视图之上。现在 recyclerview 和 edittext 在键盘打开时重叠。有没有办法限制在键盘打开时底部导航视图消失?
这是我的 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Abfahrtsmonitor">
<EditText
android:id="@+id/editText"
android:layout_width="360dp"
android:layout_height="47dp"
android:ems="10"
android:hint="Suche"
android:inputType="textPersonName"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="7dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/Recycleview"
android:layout_width="370dp"
android:layout_height="441dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="4dp"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toTopOf="@+id/navigation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<android.support.design.widget.BottomNavigationView
android:layout_width="368dp"
android:layout_height="48dp"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="511dp"
android:id="@+id/navigation"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation"/>
Run Code Online (Sandbox Code Playgroud)