gpt4 book ai didi

android - 如何在android中实现工具栏的水平滚动?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:07:09 26 4
gpt4 key购买 nike

        LinearLayout standardtoolbar = new LinearLayout(context);
standardtoolbar.setMinimumWidth(10);
standardtoolbar.setMinimumHeight(50);
Bitmap toolbarBackgroundImage = SkinManager.getInstance().getImageBitmap("BarBackground");
Drawable d = new BitmapDrawable(toolbarBackgroundImage);
standardtoolbar.setBackgroundDrawable(d);
RelativeLayout.LayoutParams lpstandardtool = new RelativeLayout.LayoutParams(5, LayoutParams.WRAP_CONTENT);
lpstandardtool.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
toolbarLayout.addView(standardtoolbar, 0);
/*toolbarLayout.getScrollX();
toolbarLayout.scrollBy(5, 0);
toolbarLayout.setScrollBarStyle(0);
*/
ScrollView scroll = new ScrollView(AppController.getInstance().getCurrentActivity());
scroll.addView(toolbarLayout);

ScrollView 不适用于给定的布局。注释代码是为水平 ScrollView 编写的。但它不起作用。

最佳答案

在你的 xml 文件 example.xml

<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:layout_width="wrap_content>

<LinearLayout android:id="layout" android:layout_height="wrap_content" android:layout_width="wrap_content" android:orientation="horizontal">

</LinearLayout>
</HorizontalScrollView>

在java代码中

LinearLayout standardtoolbar = (LinearLayout)findViewById(R.id.layout);
.
.
.
layout.addView(standardtoolbar, 0);

关于android - 如何在android中实现工具栏的水平滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10412452/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com