0

新しい問題があります。

プロジェクトには、背景としてビットマップ (私は 9 パッチにしました) を含むテキストビューが必要ですが、ユーザーはマウスを使用してテキスト ボックスをサイズ変更できる ms office のテキスト ボックスのように、ジェスチャーで幅と高さのサイズを変更できます。その中のテキストは再発行されます。

ここに私のコードがあります: 1.これは、テキストビューの属性を保存するためにマークダウンすることです. publicET はテキストビューです。

                ts.setPositionX(publicET.getLeft());
                ts.setPositionY(publicET.getTop());
                ts.setLength(publicET.getBottom());
                ts.setWidth(publicET.getRight());

2.次に、このテキストビューを表示し、テキストビューのこの属性を設定します:

                TextObject tObj = new TextObject();
                tObj.setId(Integer.parseInt(String.valueOf(id)));
                tObj.setPageId(getPageNum);
                tObj.setAlbumId(albumId);
                tObj.setContent(publicET.getText().toString());
                tObj.setPositionX(textPositionX);
                tObj.setPositionY(textPositionY);
                tObj.setLength(textPositionB);
                tObj.setWidth(textPositionR);
                tObj.setColor(curPicBackColor);
                tObj.setSize(curTextFontSize);
                tObj.setTextFont(typefacestr);
                publicET.setTag(tObj);
                publicET.setBackgroundDrawable(null);

TestObject クラスは次のようになります。

public class TextObject {

private Integer id;
private Integer pageId;
private Integer albumId;
private String content;
private Integer positionX;
private Integer positionY;
private Integer length;
private Integer width;
private String color;
private Integer size;
private String textFont;

public Integer getId() {
    return id;
}
public void setId(Integer id) {
    this.id = id;
}
public Integer getPageId() {
    return pageId;
}
public void setPageId(Integer pageId) {
    this.pageId = pageId;
}
public Integer getAlbumId() {
    return albumId;
}
public void setAlbumId(Integer albumId) {
    this.albumId = albumId;
}
public String getContent() {
    return content;
}
public void setContent(String content) {
    this.content = content;
}
public Integer getPositionX() {
    return positionX;
}
public void setPositionX(Integer positionX) {
    this.positionX = positionX;
}
public Integer getPositionY() {
    return positionY;
}
public void setPositionY(Integer positionY) {
    this.positionY = positionY;
}
public Integer getLength() {
    return length;
}
public void setLength(Integer length) {
    this.length = length;
}
public Integer getWidth() {
    return width;
}
public void setWidth(Integer width) {
    this.width = width;
}
public String getColor() {
    return color;
}
public void setColor(String color) {
    this.color = color;
}
public Integer getSize() {
    return size;
}
public void setSize(Integer size) {
    this.size = size;
}
public String getTextFont() {
    return textFont;
}
public void setTextFont(String textFont) {
    this.textFont = textFont;
}

}

この textView の属性を制御して、適切な場所に表示することはできません。ログで位置を確認しましたが正しいです。あなたが私を助けるのを楽しみにしています。ありがとうございました。

4

1 に答える 1

0

私のコードがあり、それは動作します:

RelativeLayout.LayoutParams paramst = new RelativeLayout.LayoutParams(
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
        paramst.setMargins(o.getPositionX(), o.getPositionY(),
                o.getWidth(), o.getLength());
        TextView e = new TextView(this);        
        e.setBackgroundResource(R.drawable.edittext_bg2);
        e.setLayoutParams(paramst);
        e.setWidth(o.getWidth()-o.getPositionX());
于 2013-11-02T10:47:13.253 に答える