更改布局内容的方向而无需更改“ android:supportsRtl”

时间:2019-04-09 06:30:57

标签: android

我正在为import com.google.protobuf.InvalidProtocolBufferException; import com.testnetdeve.custom.proto.AlarmProto; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.handler.codec.protobuf.ProtobufDecoder; import io.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder; import org.junit.Test; public class AlarmProtoTest { @Test public void testAlarmProto(){ AlarmProto.Alarm.Builder builder = AlarmProto.Alarm.newBuilder(); builder.setCommunity("Quene Home"); builder.setBuildingId(31); builder.setBuildingPart("B"); builder.setCellId(1); builder.setRoomId(204); builder.setAlarmCategory("Fire"); builder.setAttachment("current time"); EmbeddedChannel ch = new EmbeddedChannel(); ch.pipeline().addLast("frameDecoder",new ProtobufVarint32FrameDecoder()); ch.pipeline().addLast("decoder",new ProtobufDecoder(AlarmProto.Alarm.getDefaultInstance())); byte[] bytes = builder.build().toByteArray(); System.out.println("the length of after being serialized: " + bytes.length); ByteBuf buf = Unpooled.copiedBuffer(bytes); System.out.println(buf.readableBytes()); assert ch.writeInbound(buf); assert ch.finish(); AlarmProto.Alarm alarm = ch.readInbound(); System.out.println(alarm.toString()); } } 创建一个需要false的项目,但是要使RelativeLayout的内容将android: supportsRtl更改为direction,应该如何是吗?

我的rtl代码:

Manifest.xml

这是我的布局xml代码:

 android:supportsRtl="false"

2 个答案:

答案 0 :(得分:0)

使用View.setScaleX(-1f)View.setRotationY(180f)水平翻转视图。

答案 1 :(得分:0)

旋转该视图-

yourView.setRotationY(180f)

在您的情况下,向您的父级相对布局添加一个ID并进行设置。

yourRelativeLayout.setRotationY(180f)