CheckedTextView中的文本无法居中

时间:2016-05-24 02:49:17

标签: android android-layout

 <CheckedTextView
            android:id="@+id/charge_industry_textView"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawableTop="@drawable/charge3"
            android:gravity="center"
            android:text="@string/ChargeIndustry"
            android:background="@drawable/checkedtextview_checked"/>

enter image description here

当我CheckedTextView

时,android:gravity="center"中的文字无法居中

3 个答案:

答案 0 :(得分:5)

尝试android:layout_centerHorizontal="true"

android:textAlignment="center"

答案 1 :(得分:1)

你可以尝试用android替换:gravity =&#34; center&#34;。我希望它能起作用..它对我有用......

android:gravity="center_horizontal|center_vertical"

答案 2 :(得分:0)

对我有用的解决方案:

适用于中心

中的文字
import webpack from 'webpack';
import path from 'path';

export default {
  debug: true,
  devtool: 'inline-source-map',
  noInfo: false,
  entry: [
    'eventsource-polyfill', // necessary for hot reloading with IE
    'webpack-hot-middleware/client?reload=true', //note that it reloads the page if hot module reloading fails.
    path.resolve(__dirname, 'src/index')
  ],
  target: 'web',
  output: {
    path: __dirname + '/dist', // Note: Physical files are only output by the production build task `npm run build`.
    publicPath: '/',
    filename: 'bundle.js'
  },
  devServer: {
    contentBase: path.resolve(__dirname, 'src')
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin()
  ],
  module: {
        loaders: [
      {test: /\.js$/, include: path.join(__dirname, 'src'), exclude: /node_modules/, loaders: ['babel','babel-loader']},
      {test: /(\.css)$/, loaders: ['style', 'css']},    
            {test: /\.(jpe?g|gif|svg)$/i, loader: "file-loader?name=/public/icons/[name].[ext]"},
      {test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file'},
      {test: /\.(woff|woff2)$/, loader: 'url?prefix=font/&limit=5000'},
      {test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/octet-stream'},
      {test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=image/svg+xml'}
    ]
  },
    node: {
  fs: 'empty',
    child_process:'empty'
    }
};

右侧/结束

上的文字
                android:textAlignment="center"

android:gravity 标签在其案例中毫无用处