TextView:获取x和y作为最后一行的结尾

时间:2019-02-13 00:59:25

标签: android layout textview

我有一个<table class="table table-hover"> <thead> <tr style="background-color: #fff "> <th scope="col">イメージ</th> <th style="width:175px;"scope="col">物件名</th> <th style="width:175px;"scope="col">住所</th> <th scope="col">販売価格</th> <th scope="col">間取り</th> <th scope="col">専有面積</th> <th scope="col">坪単価</th> <th style="width:90px;" scope="col">物件詳細</th> </tr> </thead> <tbody> <tr v-for="estate in estates"> <td><img id="image" :src="estate.image" alt=""></td> <td>{{estate.building_name}}</td> <td>{{estate.address}}</td> <td>{{priceSep(estate.price)}} 万円</td> <td>{{estate.rooms}}</td> <td>{{xtendSep(estate.extend)}} m²</td> <td>{{estate.m2_price}}</td> <td><a :href="/pages/+estate.id">物件詳細</a></td> </tr> </tbody> </table> <button v-if="visible" class="btn btn-primary loadmorebutton" @click="handleButton">Load more</button>,它有多行文本,我想在最后一行文本的末尾显示一个图标。我尝试了几种获取textview的x和y值的方法:

TextView

这没有给我正确的值。那么,如何为 myTextView.viewTreeObserver.addOnGlobalLayoutListener { val layout = myTextView.layout val lines = myTextView.lineCount val myImage = ImageView(activity) myImage.imageResource = R.drawable.ic_icon // a few ways I tried val possibleY = layout.getLineTop(lines).toFloat() streamTitleView.measure(0, 0) val possibleY2= myTextView.top.toFloat() // same for x value myImage.x= //x end of last line of text myImage.y= //y end of last line of text content.addView(myImage) } 中的最后一行的文本获取x和y,以便我可以使用这些值为我的imageview设置x和y?

1 个答案:

答案 0 :(得分:-1)

您是否曾经尝试使用image.getX()image.getY()来获得它?也许可以帮助您获取X和Y坐标的位置