我在做一个待办事项应用。基本上,我希望屏幕开始时只有一个顶部的添加按钮。当用户单击按钮时,按钮向下滑动,用户可以输入仅适合一行/两行的字符。用户一次只能输入10-15个这样的任务,每次按钮向下滑动相同的距离。我该怎么做呢?下面是我编写的当前xml代码:
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView"
app:layout_constraintVertical_bias="0.111" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:text="Button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/list_view" />
另外,我知道listview属性可能是关闭的。我会尝试通过谷歌搜索来修复它们,但如果您现在就能帮助我,我将不胜感激。把这当作一个额外的问题吧。
发布于 2018-07-25 06:36:20
在这里,如果你使用listview,那么只需在listview中添加footer即可。这是一小段代码。
TextView text = new TextView(getApplicationContext());
text.setTextColor(ContextCompat.getColor(getApplicationContext(),R.color.text_color_light));
text.setText("Block");
text.setTextSize(Math.round(getResources().getDimension(R.dimen.pad_top_bottom)-1));
text.setPadding(pad+7,pad,pad,pad);
text.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertMessage.newInstance(displayName,al,getApplicationContext()).show(getSupportFragmentManager(),"alert");
}
});
listView.addFooterView(text);
它肯定会起作用。从xml中删除Button小部件并动态添加它。(此处是textView create按钮的位置)
https://stackoverflow.com/questions/51508299
复制相似问题