如何修改TextReader控件在屏幕纵向的起始位置
==========================

#### 问题现象

[TextReader（朗读控件）](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/speech-textreader-api)在屏幕垂直方向的位置固定，可以左右拖动，如何修改其在屏幕纵向的起始位置？

#### 背景知识

TextReader：朗读控件使用AI能力将文本实时转化成语音并进行朗读，适用于一些新闻类文本内容浏览类APP，帮助用户在一些无法直接浏览文本内容的场景下，通过文本朗读来高效获取信息。

[MinibarParams](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/speech-textreader-api#section1179835142719)：用来设置Minibar初始化位置，以及与底部边框的距离。

#### 解决方案

可以通过设置参数MinibarParams中的bottom的值调整朗读控件离底部边缘的距离，从而达到修改控件在屏幕纵向的起始位置的效果，示例代码如下：

import { TextReader, TextReaderIcon, ReadStateCode } from '@kit.SpeechKit';

@Entry
@Component
struct Index {

  _/\*\*_
   _\* 待加载的文章_
   _\*/_
  @State readInfoList: TextReader.ReadInfo\[\] \= \[\];
  @State selectedReadInfo: TextReader.ReadInfo \= this.readInfoList\[0\];

  _/\*\*_
   _\* 播放状态_
   _\*/_
  @State readState: ReadStateCode \= ReadStateCode.WAITING;

  _/\*\*_
   _\* 用于显示当前页的按钮状态_
   _\*/_
  private isInit: boolean \= false;

  async aboutToAppear() {
    _/\*\*_
     _\* 加载数据_
     _\*/_
    let readInfoList: TextReader.ReadInfo\[\] \= \[{
      id: '001',
      title: {
        text:'水调歌头.明月几时有',
        isClickable:true
      },
      author:{
        text:'宋.苏轼',
        isClickable:true
      },
      date: {
        text:'2024/01/01',
        isClickable:false
      },
      bodyInfo: '明月几时有？把酒问青天。'
    }\];
    this.readInfoList \= readInfoList;
    this.selectedReadInfo \= this.readInfoList\[0\];
    this.init();
  }

  _/\*\*_
   _\* 初始化_
   _\*/_

  async init() {
    const readerParam: TextReader.ReaderParam \= {
      isVoiceBrandVisible: true,
      businessBrandInfo: {
        panelName: '小艺朗读',
        panelIcon: $r('app.media.startIcon')
      },
      minibarParams:{
        defaultAlignment: 1,
        bottom: 70
      }
    };
    try {
      let context: Context | undefined \= this.getUIContext().getHostContext();
      if (context) {
        await TextReader.init(context, readerParam);
        this.isInit \= true;
        this.setActionListener();
      }
    } catch (err) {
      console.error(\`TextReader failed to init. Code: ${err.code}, message: ${err.message}\`);
    }
  }

  _// 设置操作监听_
  setActionListener() {
    TextReader.on('stateChange', (state: TextReader.ReadState) \=\> {
      this.onStateChanged(state);
    });

    TextReader.on('requestMore', () \=\> {
      TextReader.loadMore(\[\], true);
    });
  }

  onStateChanged \= (state: TextReader.ReadState) \=\> {
    if (this.selectedReadInfo?.id \=== state.id) {
      this.readState \= state.state;
    } else {
      this.readState \= ReadStateCode.WAITING;
    }
  };

  build() {
    Column() {
      TextReaderIcon({ readState: this.readState })
        .margin({ right: 20 })
        .width(32)
        .height(32)
        .onClick(async () \=\> {
          try {
            await TextReader.start(this.readInfoList, this.selectedReadInfo?.id);
          } catch (err) {
            console.error(\`TextReader failed to start. Code: ${err.code}, message: ${err.message}\`);
          }
        });
    }
    .height('100%')
  }
}