请看下面的代码
<ScrollView 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"
tools:context=".DisplayResult" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:id="@+id/zodiac1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/aries"
/>
<TextView
android:id="@+id/orTxt"
android:text="Or"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView
android:id="@+id/zodiac2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/gemini"
/>
</LinearLayout>
</ScrollView>
我需要将所有内容置于LinearLayout内部。我必须使用scrollview,因为当应用程序100%完成时,将有很多信息,如果不滚动就无法一目了然。如何使这些中心?请帮忙!
更新
在滚动中使用任何布局,没有问题。但是我需要这些元素以相同的顺序(一个接一个)并居中。
参考方案
您需要将重力设置为线性布局的中心
< LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal" >
在Android Studio中设计可滚动内容时应遵循的方法是什么? - java我正在约束布局中设计我的应用程序,并将其放置在“滚动视图”下。我想放置更多的Card Views,但是在xml文件的预览中没有放置空间。当布局已满时,我应该在哪里拖放Buttons,TextViews等?我已经处理了文本的滚动视图,但这是另外一回事。我知道我只能输入代码,但是当内容超出定义的屏幕尺寸时,我将无法看到我正在设计的内容时,我将很难这样做。(如果您…
为什么我的应用在启动时总是崩溃-Android - java刚刚遵循了有关如何制作按钮和活动的youtube指南。我按照他的代码减小字体大小,并且在启动时一直崩溃。有人知道为什么吗?public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { su…
android-android studio模拟器中的SSL问题,在手机上可以正常工作 - java我有一个可以通过https调用网络服务的应用程序。当我在手机上运行apk时,效果很好。但是,在模拟器中,所有通过POST的SSL请求均失败,并显示以下信息: 读取错误:ssl = 0xb402be00:SSL库失败,通常是一个协议 错误 错误:100c50bf:SSL例程:ssl3_read_bytes:NO_RENEGOTIATION(外部/无聊的sl /…
纵向模式下带有图标和文字的ActionBar - java无论尝试如何,我似乎都无法在操作栏中的菜单项上以肖像模式工作时获得图像和文本。我什至试图强迫android纵向我的XML: <item android:id="@+id/menu_save" android:icon="@drawable/content" android:orderInCategory=…
Android:如何为wrap_content设置高度动画? - java我需要使用ValueAnimator来使用户拖动特定视图时出现自定义“放置字段”。 (我想将字段从gone, height = 0更改为visible, height = wrap_content)。我已经尝试过以下问题的解决方案:How to animate to wrap_content?当我在单个TextView上使用它时,答案就起作用了,但是当我尝试…