Android 如何将Gama旋转木马的布局固定到水平中心?
我在使用Gama的旋转木马框架时遇到了一个问题,因为每次我运行android应用程序时,旋转木马的布局看起来好像不起作用,但如果我删除清单文件中的android:theme=@style/AppTheme,旋转木马现在将被修复,但这并不是解决我问题的好办法,因为它还将删除我的应用程序的主题。我该怎么做才能解决这个问题 这是我的旋转木马视图的xml文件Android 如何将Gama旋转木马的布局固定到水平中心?,android,carousel,android-theme,Android,Carousel,Android Theme,我在使用Gama的旋转木马框架时遇到了一个问题,因为每次我运行android应用程序时,旋转木马的布局看起来好像不起作用,但如果我删除清单文件中的android:theme=@style/AppTheme,旋转木马现在将被修复,但这并不是解决我问题的好办法,因为它还将删除我的应用程序的主题。我该怎么做才能解决这个问题 这是我的旋转木马视图的xml文件 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:andro
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.digitalaria.gama.carousel.Carousel
android:id="@+id/carousel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#FFFFFF"/>
</LinearLayout>
这是我的旋转木马视图中单个项目/图片的xml文件
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/itemImage"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
最后,我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="bzguys.corporation.jaja"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".LoginActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="bzguys.corporation.jaja.CarouselViewActivity"
android:label="@string/app_name"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.DEFAULT" />
<category android:name="android.intent.category.CAROUSELVIEWACTIVITY" />
</intent-filter>
</activity>
</application>
</manifest>
试试这个。这可能对你有帮助 在java文件中添加这些行。首先申报旋转木马
Carousel carousel;
设置旋转木马的重力
carousel.setGravity(Gravity.CENTER_HORIZONTAL);