我试图DialogFragment弹出并显示可滚动TextView图例,但它只是切断了图例的其余部分。我无法滚动浏览它或任何东西。我尝试添加 aScrollView但它没有任何作用。这是我得到的屏幕:
这是我的 XML 布局文件:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:scrollbars="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:background="#fff">
<TextView
android:id="@+id/layer_legend_title_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:background="#fff"
android:textColor="#000" />
<ListView
android:id="@+id/layer_legend_symbols_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:background="#fff"
android:textColor="#000" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
我运行此命令将内容添加到TextView:
/**
* A dialog that shows the legend of a ArcGISDynamicMapServiceLayer.
*/
public class LegendDialogFragment extends DialogFragment implements View.OnClickListener {
public static final String TAG = LegendDialogFragment.class.getSimpleName();
private LinearLayout mLinearLayout;
private ArcGISDynamicMapServiceLayer …Run Code Online (Sandbox Code Playgroud) android arcgis android-layout android-scrollview android-dialogfragment
您如何显示一侧(水平/垂直)非常大的项目列表,并允许它自由滚动/拖动 - 就像 Google 表格一样?
我试过使用 aNestedScrollView和 a RecyclerView,但一次只能向一个方向滚动,我需要它能够自由拖动(不需要捏/缩放功能,但如果可以做到,它是一个奖金)。
这是我尝试过的 GIF,它有效,但绝对不是我想要的。
这是布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
layout="@layout/include_toolbar"
android:id="@+id/toolbar" />
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_biscroll"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) android android-scrollview android-scroll android-recyclerview android-scrolling
我有一个我无法弄清楚的奇怪行为 - 我试图将视图粘贴到滚动视图的底部,但没有运气。我已经尝试过 ClipToPadding 和 fillViewport 但没有一个有帮助。有什么帮助吗?我的 xml 布局是 -
<LinearLayout>
<FrameLayout/>
<ScrollView>
<LinearLayout>
<LinearLayout/>
<RelativeLayout/> <-- This is the problematic view
</LinearLayout>
</ScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我想将相对布局粘在底部,即使滚动视图比屏幕长度短,当clipToPadding设置为false时,它确实适合屏幕,但是相对布局只是放在屏幕中间的线性布局之后,当我在滚动视图上将 fillviewport 设置为 true (并删除 Cliptopadding),滚动视图比屏幕长但不可滚动,这导致相对布局“不可见”,有什么建议吗?
我有一个Fragment,有一个ScrollView在Fragment。
<ScrollView
android:id="@+id/scroll_view"
android:layout_width="0dp"
android:layout_height="0dp"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appbar">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.tatar.mobile.widget.CardSelectionView
android:id="@+id/card_selection_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:accountRightTextView1="@string/available"
app:accountTitleTextView="@string/from"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/line_text_view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:background="@color/gray.light"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/card_selection_view" />
<Spinner
android:id="@+id/type_spinner"
style="@style/spinner"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/line_text_view" />
<Spinner
android:id="@+id/company_spinner"
style="@style/spinner"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/type_spinner" />
<LinearLayout
android:id="@+id/dynamic_form_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/company_spinner" />
<Spinner
android:id="@+id/installment_spinner"
style="@style/spinner"
android:layout_marginTop="8dp"
android:visibility="invisible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/dynamic_form_container" />
<Button
android:id="@+id/continue_button"
style="@style/action_button"
android:layout_marginTop="16dp" …Run Code Online (Sandbox Code Playgroud) android android-softkeyboard android-fragments android-scrollview android-scroll
我有 Material App 和CustomScrollView,BottomNavigationBar在CustomScrollView我有SliverAppBar一个页面Widget(比如说 page1、page2 等...),它代表BottomNavigationBar's当前索引,每个页面上Widget都有SliverList一些内容
我尝试将 Keys 和ScrollControllers放入内部CustomScrollView,但在页面之间导航时滚动位置为初始位置时,它无法按我的预期工作。
class WrapperPage extends StatefulWidget {
@override
_WrapperPage createState() => _WrapperPage();
}
class _WrapperPage extends State<WrapperPage> {
int _curIndex = 0;
List<Widget> _pages;
List<PageStorageKey> _keys;
List<ScrollController> _ctrls;
@override
void initState() {
_pages = [
// some pages pages
];
_keys = List();
_ctrls = List();
for (int i = 0; i < …Run Code Online (Sandbox Code Playgroud) 我在 ConstraintLayout 中有一个滚动视图。但滚动视图在 ConstraintLayout 中不起作用。我尝试使用 NestedScrollView 而不是 ScrollView,但它仍然不起作用。ScrollView 在 LinearLayout 或relativelayout 中工作得很好,但在 ConstraintLayout 中不起作用。我将 android:layout_height 更改为 match_parent 和 wrap_content 但它不起作用。问题是什么?
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
>
<include
android:id="@+id/other_toolbar_xml"
layout="@layout/other_toolbar_xml"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/other_toolbar_xml"
android:fillViewport="true"
tools:ignore="MissingConstraints"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/img_content_xml"
android:layout_width="match_parent"
android:layout_height="170dp"
app:layout_constraintTop_toBottomOf="@id/other_toolbar_xml"
android:scaleType="fitXY"
tools:ignore="NotSibling"
/>
<TextView
android:id="@+id/title_content_xml"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/img_content_xml"
android:layout_marginRight="16dp"
android:paddingLeft="16dp"
android:textDirection="rtl"
android:text="title"
android:textSize="17sp"
android:textColor="#1d1d1d"
/>
<TextView
android:id="@+id/content_content_xml"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/title_content_xml"
android:layout_marginTop="20dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
android:paddingLeft="16dp"
android:textDirection="rtl"
android:text="content"
android:textColor="#1d1d1d"
/> …Run Code Online (Sandbox Code Playgroud) 我看到 React Native 提供了来自React Native Nested ScrollView Can`t Scroll on Android Device 的嵌套垂直滚动视图
问题是它似乎不适用于 Android 上的嵌套水平滚动视图。请参阅此代码的示例:
https://snack.expo.io/@harrytravelchime/broken-horizontal-scroll
import React from 'react';
import _ from 'lodash';
import { View, ScrollView, StyleSheet, Text, SafeAreaView } from 'react-native';
export default class App extends React.PureComponent {
render() {
return (
<SafeAreaView style={styles.container}>
<ScrollView
style={{ height: '100%', width: '100%' }}
horizontal
nestedScrollEnabled
>
<View style={{ flexDirection: 'row' }}>
<ScrollView
style={{ width: 200, height: '100%' }}
horizontal
nestedScrollEnabled
>
<View style={{ flexDirection: 'row' }}>
{_.times(200, …Run Code Online (Sandbox Code Playgroud) android horizontalscrollview android-scrollview react-native
如果是这样,似乎ScrollView相当蹩脚(令人怀疑)或者有其他方法可以做到这一点.这是我的代码.它被轰炸的地方(第二次通过循环,即)被评论.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ondemandandautomatic_dynamicauthorize);
ScrollView svh = (ScrollView) findViewById(R.id.scrollViewHost);
// Contacts data snippet adapted from
// http://saigeethamn.blogspot.com/2011/05/contacts-api-20-and-above-android.html
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null,
null, null, null);
if (cur.getCount() > 0) {
while (cur.moveToNext()) {
String id = cur.getString(cur
.getColumnIndex(ContactsContract.Contacts._ID));
String name = cur
.getString(cur
.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
// Create a Linear Layout for each contact?
LinearLayout llay = new LinearLayout(this);
llay.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llp = new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
llp.weight = 1.0f;
CheckBox cbOnDemand = new …Run Code Online (Sandbox Code Playgroud) android dynamic android-widget android-layout android-scrollview
我有一个滚动视图,其中我有几个相对布局.并且相对布局有两个按钮动态添加到它.如下所示
滚动视图
_____________________
| ________________ |
| |Relative Layout| |
| | |Buttons| | |
| |_______________|
| |
| ________________ |
| |Relative Layout| |
| | |Buttons| | |
| |_______________|
| |
| |Relative Layout| |
| | |Buttons| | |
| |_______________|
| |
| ________________ |
| |Relative Layout| |
| | |Buttons| | |
| |_______________|
| |
| |Relative Layout| |
| | |Buttons| | |
| |
|_____________________|
Run Code Online (Sandbox Code Playgroud)
是否可以在按钮单击时动态滚动到特定的相对布局.我已经在下面尝试了它不起作用
if (count == …Run Code Online (Sandbox Code Playgroud) 我正在开发一个应用程序,其中我是一个结构点.
根据我的应用程序要求,我在xml中创建了水平scrollview,然后在.java中创建了垂直scrollview:
// Vertical Scroll view in Linear layout
ScrollView scrollView = new ScrollView(this);
scrollView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
Run Code Online (Sandbox Code Playgroud)
然后我以编程方式创建了一个表视图,并将其添加到scrollview中.我创建了多行编辑文本并禁用它,因为我想在运行时设置文本并将其作为一行添加到表视图中.
EditText editText = new EditText(this);
editText.setId(1);
editText.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,0f));
editText.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
editText.setGravity(Gravity.TOP|Gravity.LEFT);
editText.setHint("Comment");
editText.setSingleLine(false);
editText.setLines(5);
editText.setMaxLines(5);
editText.setText(CommentFromDB);
editText.setEnabled(false);
tableLayout.addView(editText);
// Add table in Horizontal scroll view
scrollView.addView(tableLayout);
Run Code Online (Sandbox Code Playgroud)
现在我想使编辑文本可滚动,我通过代码实现:
editText.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View view, MotionEvent event) {
if (view.getId() == 1) {
view.getParent().requestDisallowInterceptTouchEvent(true);
switch (event.getAction()&MotionEvent.ACTION_MASK){
case MotionEvent.ACTION_UP:
view.getParent().requestDisallowInterceptTouchEvent(false);
break;
case MotionEvent.ACTION_DOWN:
view.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
}
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
但是edittext不容易滚动.我需要平滑滚动.
怎么做请指导我.
android android-ui android-scrollbar android-edittext android-scrollview